Menu

[Solved]Modify C Loop Program Project 4 Book Sale Calculator Accept Input External Data File Name Q37137443

Modify the C++ Loop program (Project #4 – Book Sale Calculator)to accept all input from an external data file, the name of whichis entered by the user, rather than from user input via thekeyboard. The final summary displayed for each book sale shouldbegin with the number of the sale so the individual summaries arevisually separated on the screen. Otherwise, the projectspecifications remain the same.

Your program should continually read data until the end of thefile is reached. No sentinel value will be used to signaltermination of the program, and you may not count the number ofitems in the file and use a count controlled loop to obtain thedata. The data will be stored in the file such that the number ofbooks in each sale is on one line, the prices of all books in thatsale are on the next line, and the single character coderepresenting the shipping method used for that sale is on thefollowing line.

You may assume the data file has no errors. Specifically, thedata file will contain information for at least one sale, the datafor each sale will be stored in the order and manner describedabove, each sale will consist of at least one book, the price ofeach book will be a non-negative value, and the shipping method foreach sale will consist of a single capital letter that representsone of the available options.

As a minimum, your program must include a single function foreach of the following (additional functions, including subdivisionof these into multiple functions, may be used if necessary ordesired):

  1. Obtain the name of the data file from the user and attempt toopen it for reading. If the attempt to open the file fails, theprogram should report an appropriate error message and quit.
  2. Obtain all input for each sale from the data file. The functionshould return the merchandise total and shipping method for thecurrent sale being processed.
  3. Calculate all discounts, fees, taxes, and any other relateditems for each sale.
  4. Display a final summary for each sale.

No global variables may be used. All information must be sharedbetween functions via parameters and return values. Your mainfunction should be primarily variable declarations and functioncalls, but a control loop for reading each sale from the file maybe there rather than in a separate function if desired.

Book Sale Calculator Example output based on anotherbooksale.dat the data for file is found below

====================

Enter the filename of the data file: booksalesample.dat

      The summary for order #1 is asfollows:

          MerchandiseTotal: $ 75.25

                 Discount: $ 7.53

                 Shipping: $ 4.99

                 Subtotal: $ 72.71

                Sales Tax: $ 4.36

                    Total: $ 77.08

      The summary for order #2 is asfollows:

          MerchandiseTotal: $ 34.95

                 Discount: $ 0.00

                 Shipping: $ 12.99

                 Subtotal: $ 47.94

                Sales Tax: $ 2.88

                    Total: $ 50.82

      The summary for order #3 is asfollows:

          MerchandiseTotal: $ 29.02

                 Discount: $ 0.00

                 Shipping: $ 12.99

                 Subtotal: $ 42.01

                Sales Tax: $ 2.52

                    Total: $ 44.53

      The summary for order #4 is asfollows:

          MerchandiseTotal: $122.11

                 Discount: $ 18.32

                 Shipping: $ 4.99

                 Subtotal: $108.78

                Sales Tax: $ 6.53

                    Total: $115.31

booksale.dat has values as follows: Number of books, cost ofeach book, then Shipping method of standard or expedited

3
14.99 42.99 27.95
E
5
31.45 22.99 10 27.19 59.95
S
4
12.99 0 7 14.5
E

Expert Answer


Answer to Modify the C++ Loop program (Project #4 – Book Sale Calculator) to accept all input from an external data file, the na… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *