Question: A. Make a program called FriendAges.java that creates variables to store the names of four friends, and separate variables to store the ages of

A. Make a program called FriendAges.java that creates variables to store the

 

A. Make a program called FriendAges.java that creates variables to store the names of four friends, and separate variables to store the ages of those friends. Next, add up the ages of all four friends and store the result in an additional variable; then use division to calculate their average age and put the result in its own variable. Finally, output the name and age of each person, as well as the sum and average of their ages. This part does not require user input or test cases--the program just runs and outputs as directed. B. Write a program called GasPrice.java that defines a named constant to represent the price of gas per gallon for regular gas, and a second named constant for the price per gallon of premium gas. Prompt the user to input how much gas they need. Calculate the cost of purchasing each option (using those constants) and save the results in two variables. Finally, output the results. Be sure to include test cases as shown earlier in this Module. Sample program run for Part B, with user input. Note that yours doesn't need to match exactly. How many gallons of gas do you wish to purchase? 16 Total for regular gas at 3.29 per gallon: $52.64 Total for premium gas at 3.49 per gallon: $55.84

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!