Hello everyone! I would like some help on a program I'm currently writing. I need to display a receipt that shows 4 items with their quantity, unit price, and total as well as the sub-total, tax and final total. This is what I have so far.
So what you need to do now is think how you will handle 4 items as far as getting the data in, how to store it and then how to process it.
That might mean a for 1 to 4 loop, some cin's, at least one array ( a <vector> and structs are probably out of the question ?? ), a variable(s) for subtotals and grand total, and a print heading (you've already got that bit), followed by printing the details.
Perhaps if you try it on paper first, then write some pseudo-code, and then write some real code. Otherwise we'd just be doing it for you and so far you're doing OK with printing out a receipt.
When I tested your program it printed the beginning of the receipt then asked for input.
So, essentially you start the receipt then ask for input before you would finish the receipt. It would not look very good on the screen.
Lines 8 - 13 should be done near the end of the program after all your input.
Your input is for quantity and price, but not for an item name or description of the item. For this part you need to decide on how you will store the information before you get to printing the receipt.
Another aspect you might consider is using functions if you're up to that in your studies. You could have a function to print the heading info, which means you can a? work on it separately and b) print the heading at whatever stage you like.
Also you could use all the same heading info and store it as a single string called str_heading or whatever. Then to print it you just
This is only set up for 1 input, but it should give you an idea:
Enter item description: Bread
Enter the price of Item: 1.95
Enter the item's quantity: 3
Colin's Capital Ventures
25 W Hill Drive,
West Hartford, CT, 06119
(203) 860-2478
-------------------------------------------------
Tue Nov 24 02:35:15 2020
CASHIER: Colin
Item QTY Unit Price Total
-------------------------------------------------
Bread 3 1.95 5.85
Bread 300 1.95 585.00
=================================================
SubTotal 5.85
Tax 5.85
Total 5.85
Press Enter to continue:
The second item line is an example of how larger number display. The tax ang total lines are for examples. Not yet dealt with.