Question
Programming Language in c++ Please put each output into the same file. Project Description: Your project will calculate and output a bill based on a
Programming Language in c++ Please put each output into the same file.
Project Description:
Your project will calculate and output a bill based on a Dunkin Donuts order. The customer name and order will be input from a file. The customer can order coffee, bagels and muffins. Only one size and type of coffee is available. A coffee costs $3.00, bagels cost $1.50 each and a muffin costs $2.28. The item prices are to be declared as constants in the appropriate function.
Once the order has been read from the file, a bill is to be output in the following format shown below where the XXX's will be filled in with the appropriate data. The program will then read (from the file) the amount the customer gives the clerk in response to the total bill. Your program should then calculate the correct change the customer will receive. The change will consist of one dollar bills, quarters, nickels, dimes and pennies in the highest amount possible for each. For example, if a customer bought 1 coffee, 1 bagel and 1 muffin the bill would come to $6.78. If the customer gave the clerk $10.00, the clerk would then be instructed to return 3 dollars, 0 quarters, 2 dimes, 0 nickel and 2 pennies. Your project will have 4 functions (main, calcBill, validation, and calcChange). The functions and their outputs are described and shown below. An end of file loop will be used to read all orders.
Your code must include three functions in addition to main:
1. The first functions (calcBill) will:
1. Declare local constant variables to store the prices;
2. Get the order from a data file;
3. Calculate the subtotals and total;
4. Output the bill in the following format to an the output file:
Name, WELCOME TO DUNKS
XX COFFEES $XXX.XX
XX BAGELS XXX.XX
XX MUFFINS XXX.XX
---------------
ORDER TOTAL $XXX.XX
2. The second function (validation) will return a boolean and it will be called from the calcBill function. The validation function will determine whether the input is valid and return true to the calcBill function or false if invalid. Do not use a validation loop in this function. Only determine if the data is valid or not. If the input is invalid, do not continue with outputting the bill or the change. The validation function will output an error message to the file and the data input in error.
3. The third function (calcChange) will:
1. Get the amount tendered (customers money to the clerk) from the file;
2. Calculate the total change and the change by denominations;
3. Output the change in the following format to the output file:
Amount Tendered $XXX.XX
Change:
XX Dollar Bills
XX Quarters
XX Dimes
XX Nickels
XX Pennies
Use the input listed below for your input file. Once again, all data is to be output to a file. Only use one run.
Run your program with the data shown below. If the data is invalid, print an appropriate message and move on to the next input. The amount tendered must exceed the total bill.
Name Coffee Bagels Muffins Amount Tendered
John` 1 1 1 10.00
Sue 7 1 2 30.00
Paul 1 0 0 5.00
Sam -1 2 2 10.00
Neal 1 5 -1 10.00
Nan 1 -1 0 10.00
Kay 1 0 0 5.00
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started