Read the information for one purchase into a variable of


Computer Science Program-

Write a C++ program that will simulate a store where the purchase information will be read in from an input file. The program will calculate the price per item and the total cost of the entire purchase. The output will use formatted output tools to provide spacing and the exact number of decimal places to be displayed.

Declare a struct type that will represent a single purchase. The required fields are:
Item name - string
Quantity of items (how many are being purchased) - int
Cost (what does it cost to buy that many items) - double
Price per item (a calculated value based on quantity and cost) - double

The program should

Ask the user for the name of the input file and open that file for reading
While there is more purchase information in the file

read the information for one purchase into a variable of your struct type.
calculate the price per item for that purchase
output the data in formatted columns (as in program #1)
add the item cost into a total cost variable

After all file data has been processed, write out the total cost line

For an input file containing
Pencils
3
12.4
BlueBooks 13
3.99
the output would look something like this

Qty

Item

Price/Item

Cost

3

Pencils

4.13

12.40

13

BlueBooks

0.31

3.99

 

 

Total Cost

16.39

Use functions to do all of the major tasks (input, calculation, output)

Required Comments: Name block

Descriptive comment at the beginning of the whole program Descriptive comment at the beginning of each function

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: Read the information for one purchase into a variable of
Reference No:- TGS01624406

Now Priced at $40 (50% Discount)

Recommended (94%)

Rated (4.6/5)