Assignment: Write a program (Book Sale Calculator) that accepts all input from an external data file and displays a summary for each book sale. The program needs to open the external data file ([url removed, login to view]) and continue to read in data until the end of the file is reached. No sentinel value can be used to signal termination, and you cannot count the number of items in the file or use a count controlled loop to obtain the data. The data file is stored so that the number of books in each sale and the single character code for shipping (S = Standard which is 4.99 and E for Expedited is 12.99) representing the shipping method is on one line, and the prices for all of the books are on the second line.
Create four functions for the following:
(1) Obtain the name of the data file and attempt to open it for reading. If the attempt to open the file fails, the program should report an appropriate error message and quit.
(2) Obtain all input for each sale from the data file. This function should return the merchandise subtotal and shipping method for the current sale being processed.
(3) Calculate all taxes and discounts.
(4) Display a final summary for each sale.
The sales tax is .05%
Discounts are as follows:
* If the subtotal is < $50, there is no discount
* If the subtotal is between $50-$100, the discount is 10%
* If the subtotal is above $100, the discount is 15%
Additionally, no global variables can be used and all information must be shared between functions via parameters and return values. The main function should consist of variable declarations, function calls, and a control loop for reading each sale from the file can be there.
The external data file name ([url removed, login to view]) consists of the following format:
2.99 12.45 13.23 21.99 24.59
8.99 12.45 7.58
5.66 12.35 23.56 40 12.99 16.32 11.23
****A sample output of the program:****
The summary for order #1 is as follows:
The summary for order #2 is as follows:
The summary for order #3 is as follows:
The summary for order #4 is as follows:
Thanks for shopping with us. Come again!