Question: Book Purchase Invoice Write a C++ program that reads book purchasing /order information from a file. There will be multiple lines in the file and

Book Purchase Invoice Write a C++ program that reads book purchasing /order information from a file. There will be multiple lines in the file and each line in the file will represent the purchase of a book by a customer . Each customer will generally buy multiple copies of each book for their book club. Each line will contain the following information about the book : Customer ID Title Author ISBN Price Quanti ty Fiction/Non - Fiction Genre The file will contain o rdering information for 4 or 5 different customers . Here is an example of the data (note there will be no column headers in the file): 1234 Once_Upon_A_Time New_Author 1234323456787 25.00 4 N M 2345 Midnight_Moon Margaret_Brown 3456789765432 50.00 10 F D 3456 A_Wrinkle_In_Time Madeline_Engle 2535483215987 60.00 4 N M 4567 Harry_Potter J_K_Rowling 0002569854712 100.00 100 F D 5678 Charlottes_Web E_B_White 036250125478 25.00 12 F M 6789 The_Snowy_Day Ezra_Keats 00025523148 50.00 5 N R Make use of the follow ing data types: C++ string double int char bool Additional Requirements: Assume the tax on the total price of the books is 7% Shipping fee: If the quantity is Over 20 Fee $50, 15 - 19 Fee $40, 10 - 14 : Fee $30, 5 - 10 : Fee $20, less than 5 Fee $10 Use and if/else if or switch to determine the fee Tax should not be calculated on the fees A Boolean variable should be used to hold whether the book is Fiction or Non - fiction Do not apply fee to non - fiction romance Accumu late total sales (without tax and fees ) of all invoices for this batch (file) Accumulate total number of book orders in this batch Display the average book order sale Do not use arrays for this project. Process one line at a time (read, accumulate, calculate, print to file) use the following function calls (you can name the function names different, and name the variables differently, but you must utilize all functions listed: bool isBookFiction( char fiction ) double getFee( int q uantity , char genre , bool isFiction ) double calcBookSalesAndTax( double price , int quantity , double & taxTotal ) string setGenre( char genre ) void printoutput( ofstream & outPutFile , string customerID , string bookTitle , string bookGenre , bool isFiction , int quantity , double price , double subTotal , double taxTotal , double extraFee , double total ) void displayTotals( ofstream & outPutFile , double totalSales , int totalOrders ) Take this project one step at a time: 1. Loop through and read the data into variables 2. With in your loop, next process a single line file (you should have the code for this from your last project) 3. Call isBookFiction sending it the char received from the file and set your isFiction variable 4. Call getFee to set your fee variable, all logic to determine fee is in this single function 5. Call calcBookSales and Tax, this MUST be a function that uses both a byValue and byRef parameter, it does not matter is sales (just quantity * price) is byRef or t axTotal (quantity*price*.07) is byRef I am testing you on byRef and byVal with this function and you will lose significant points if you do not demonstrate that you understand how to use them 6. Call setGenre to set the char form the file to a variable that holds the word (e.g. send it r or R for romance string bookGenre = setGenre(r) ; - would result in bookGenre = Romance 7. Call a void function printOutput to print the output to the file, send your output file handler byRef. Send all the information you need to print each individual invoice. 8. Still within your loop accumulate your total variables ( keep total book sales and the number of book sales (lines) ) 9. Once your loop is complete call void displayTotals to write the total book sales and average book order. 10. Close your file handlers Test after each step!!! Pseu do code: Includes Function prototypes Main: Declare variables Open file handlers While not e nd of file Read a single line and store information to variables Call functions to set all variables Accumulate the total sales and number of book orders (a book order is one line in the file) Write invoice informati on for that one line to the file Move to next line in file End while Write totals to file (total sales and average book order) Close files Function bodies Example Output REMEMBER: I will use different data, you can use this to test your work, but your program must work with different data sets. (I will use a different file when I test your program, however you can use the file given to test your work.) Print Invoice (i nclude the lines) to a n invoice.txt file, you should have an entry like this for each unique customer id: _______________ ________________ ______________________________ _______________________________________________________________________________ Invoice Customer ID: 1234 Once_Upon_A_Time Fiction Mystery 4@25.00 Subtotal: 100.00 Total Book Sales: 100.00 Tax: 7.00 Subtotal: 107.00 Extra Fee: 10.00 Total: 117.00 _______________________________________________________________________________ ____________________________________________________ ___________________________ Invoice Customer ID: 2345 Midnight_Moon Fiction Drama 10@50.00 Subtotal: 500.00 Total Book Sales: 500.00 Tax: 35.00 Subtotal: 535.00 Extra Fee: 30.00 Total: 565.00 _______________________________________________________________________________ _______________________________________________________________________________ Invoice Customer ID: 3456 A_Wrinkle_In_Time Fiction Mystery 4@60.00 Subtotal: 240.00

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!