Module 1 Coding Practice

Update the main method in E01Rectangle to calculate and print the perimeter of a rectangle having width 7 and height 9. Add another statement to calculate and print the area of the rectangle on a separate line.

Update the main method in TriangleTest to calculate and print the area of a triangle with base 7 and height 9. Recall the formula is 1/2bh. Your solution must contain at least one multiplication and one division. Watch out for integer division! int/int results in an int, while int/double results in a double.

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

The E04Color program 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.

Finish the E05Age program so that it prints “Your name is Justin and your age is 16” using the variables provided.

Open the E06Pizza program. Write the code to print “Julian’s favorite color is green. His favorite food is pizza.” using the variables provided. Watch out for spaces and the period at the end of each sentence.

Finish the E07BookAndMovie program to print your favorite movie and book.

The E08MilesPerGallon1 program should calculate the cost of a trip that is 300 miles if gas is $2.50 a gallon and your car gets 36 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.

The E09MilesPerGallon2 program 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.

The E10Clearance program 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.

The E11Days program 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.

Complete the E12Savings program to calculate and print how many months it will take to save $200 if you earn $20 a week. First calculate how many weeks it would take to make $200, then calculate how many months it will take assuming there are 4 weeks per month.

Complete the E13TripDistance program 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.

Complete the E14Seconds program 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.

Complete the E15ChickenWings program 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. Divide the amount of money you have by the cost of each wing and then use casting to set the result to an int since you can’t buy a part of a wing.

You have attempted of activities on this page