# Coding Practice 1a (1.1-1.6)

Each coding exercise has its own folder. Open its `.java` file and press **Run** to try it. **Run Tests** checks every graded exercise in this lesson at once.

## Exercise 1

The code should print “Mary’s favorite color is blue”. However, the code has errors. Fix the code so that it compiles and runs correctly.

> Open the `01-u1afix1` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 2

The code should print “Gabby’s favorite sport is soccer”. However, the code has errors. Fix the code so that it compiles and runs correctly.

> Open the `02-u1afix2` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 3

The code should print `Your name is Carly and your favorite color is red`. Finish the code so that it prints the output correctly using the variables provided.

> Open the `03-u1afix3` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 4

Finish the code so that it prints `Your name is Justin and your age is 16` using the variables provided.

> Open the `04-u1afix4` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 5

Write the code to print `Julian's favorite color is green. His favorite food is pizza.` using the variables provided.

> Open the `05-u1afix5` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 6

Finish the code to print your favorite animal and food.

> Open the `06-u1afix6` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests). Its tests check your code, not what it prints: “Code prints animal variable”, “Code prints food variable”.

## Exercise 7

Finish the code to print your favorite movie and book.

> Open the `07-u1aconcat` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests). Its tests check your code, not what it prints: “Code prints movie variable”, “Code prints book variable”.

## Exercise 8

The code should calculate the cost of a trip that is 300 miles if gas is $2.50 a gallon and your car gets 30 miles per gallon. However, the code has syntax errors, like missing semicolons, wrong case on names, or unmatched `"` or `(`. Fix the code so that it compiles and runs correctly.

> Open the `08-u1acosts` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 9

The code should calculate the body mass index (BMI) for someone who is 5 feet tall and weighs 110 pounds. However, the code has syntax errors, like missing semicolons, wrong case on names, or unmatched `"` or `(`. Fix the code so that it compiles and runs correctly.

> Open the `09-u1abmi` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 10

The code should calculate the number of miles that you can drive when you have $8.00 and the price of gas is 2.35 and the car gets 40 miles per gallon. However, the code has errors. Fix the code so that it compiles and runs correctly.

> Open the `10-u1amiles` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 11

The code should calculate the cost of an item that is on clearance (70% off) when you also have a coupon for an additional 20% off the clearance price. However, the code has errors. Fix the code so that it compiles and runs correctly.

> Open the `11-u1aclearance` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 12

The code should calculate the number of whole days in 320893 seconds. However, the code has errors. Fix the code so that it compiles and runs correctly.

> Open the `12-u1adays` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (1 test).

## Exercise 13

Complete the code to calculate and print how many months it will take to save $200 if you earn $20 a week.

> Open the `13-u1amonths` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 14

Write the code to calculate the number of miles you can drive if you have a 10 gallon gas tank and are down to a quarter of a tank of gas and your car gets 32 miles per gallon.

> Open the `14-u1snumMiles` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 15

Write the code to calculate the number of seconds in 3 days. Remember that there are 60 seconds in a minute and 60 minutes in an hour and 24 hours in a day.

> Open the `15-u1anumSecs` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).

## Exercise 16

Write the code to print the number of chicken wings you can buy if you have $4.50 and they cost $0.75 each. Remember that you can’t buy part of a wing.

> Open the `16-u1awings` folder and edit `Test1.java`. Press **Run** to try it; **Run Tests** checks it (2 tests).
