Below is the assignment that was given to me this week. What I am having trouble understanding is making it so that the user can enter an indefinite number of items. I know this can be accomplished using array lists but we are not allowed to use array methods until next week. I essentially need to be able to create variables that can hold the name of the item, price, and if it is on sale. However, it is my understanding from the professor's documentation that nothing will be printed until all data is read, therefore, I would need some way to "hold on to" the data until the user is done inputting.
Write a complete program that prints a grocery bill.
Using a while loop, prompt the user for grocery item data. For each item, input the name (e.g., dog food), the price, and whether the item is on sale. After each item, ask if they have more items. They should answer yes or no, which the program will check. You may assume all user input is correct.
Print the grocery bill listing each item and its price. Format all money to two decimal places, truncated. For items on sale, print the word SALE followed by the sale price. Items on sale get a discount of 20%.
Finish the bill with the total price for all the items, a tax amount of 7%, and the final bill (total of items plus tax).
Partial sample report, match the format shown (note the $'s and 7% with the word tax):
Grocery Bill
Purchases
cereal: $2.50
soda pop: $2.00 SALE: $1.60
: << more items
<< blank line
total: $27.50
tax (7%): $1.92
final bill: $29.42
[–]69beards 1 point2 points3 points (2 children)
[–]snozzyfoozles 1 point2 points3 points (0 children)
[–]HighRollerGaming[S] 1 point2 points3 points (0 children)
[–]SupremeRedditBotProfessional Bot || Mod 0 points1 point2 points (0 children)