Young college students who are living alone for the first time often find grocery shopping to be one of the biggest pains. Besides the simple fact that they are busy and don’t have time to go to the store, it is often difficult to add up and calculate how much money is needed to buy everything that has been put into the shopping cart. This program will help to simplify that problem.
You will write a program that will accept a list of 5 grocery items along with their prices. The program should calculate the total cost of the items on a line-by-line basis and format the output so it looks clean and even.
Prompt the user for the cost of item #1.
-
Repeat step # 1 four additional times.
-
When you have accepted all the values, print them to the screen with a total value printed next to them. Make sure everything is straight and aligned.
- Here is a sample run:
Enter item #1: 2.59
Enter item #2: 5.25
Enter item #3: 6.34
Enter item #4: 4.50
Enter item #5: 8.72
- Set all your width specifications to 10 and all your precision to 2, where appropriate. Instead of using any regular spaces to align your columns, only use the printf method. Use the println method only for changing lines.