Project Summary: You will develop a C++ program that will be used by a cashier a
ID: 3536256 • Letter: P
Question
Project Summary: You will develop a C++ program that will be used by a cashier at a grocery store. The program will read some input from a file regarding the items customers purchased and print one of more purchase receipts into another file.
Scoring: You are expected to fully test your program with various inputs to make it robust. You will be graded for correct output produced by the program. You will also be graded on correct programming/coding style as discussed in the class as well as efficient programming.
Submission Guidelines: Please submit one ZIP file. Attach the ZIP file under Assignment#7 under the assignment sections on our blackboard site. Your ZIP file MUST include: i) Code (.CPP) file ii) Screenshots of your runs (give me various screenshots).
Project Description: When the program launches, it will ask Cashier for: Store Number, State, Cashier Name at the beginning. Then the program will read an input file called %u201Ctransactions.log%u201D which will contain all the purchases for one or more customers.
In the file, the following information will be present for each item, each customer buys: product name, quantity and unit price. The program will add the total prices for each item and calculate the sub total.
Sale: If the user purchased: $25 %u2013 $40 worth of grocery, give him a 15% discount. If the user purchased: $50+ worth grocery then give him a 20% discount.
State Tax: If the state is MD, add a 6% tax. If the state is NY, add a 8% tax. If cashier enters any other state, keep looping and keep asking to enter a valid state, until the cahier does so.
Notice, in the input file, each customer%u2019s transactions are separated by 10 dashes %u201C----------%u201C. So when you see %u201C----------%u201C in a line by itself, you can assume the first customer%u2019s transaction ended. Prepare a receipt for him/her. Then move on to the second customer and so forth.
Rules to Implement
There is NO LIMIT to how many customers I can test with and there is NO limit to how many items a customer can buy.
Keep asking for a valid state until cashier enters MD or NY (either case is fine such as lower case md is accepted).
Generate one file %u201Creceipts.log%u201D which contains all the receipts.
The program will keep reading the file until there is no more lines to read.
Define and use following functions: getCashierAndStoreInfo(), readOneTransaction(), calculateTotal(), printRecipt().
Validate such that, if a item unit price is more than $5,000, write an error in the receipts.txt saying %u201CItem X is over $5,000. Unable to produce receipt%u201D. Skip calculating total and generating receipt for this customer. But continue onto the next customer.
Sample Data
Sample User Input:
Enter your name: Abraham Lincoln
Enter Store Number: 66
Enter State: NY
Sample Input in transactions.log:
Customer ID: 1
Item: Egg box
Unit Price: $2.49
Quantity: 3
Item: Post Honey Nut Cereal
Unit Price: $3.99
Quantity: 1
Item: Tropicana Orange Juice
Unit Price: $4.10
Quantity: 2
Item: Cashew Nut Can
Unit Price: $8.49
Quantity: 2
Item: Potato 5lb
Unit Price: $3.00
Quantity: 2
Item: Tomato Juice
Unit Price: $4.50
Quantity: 1
Item: Baked Onion
Unit Price: $2.00
Quantity: 1
----------
Customer ID: 2
Item: Candy Cane
Unit Price: $0.50
Quantity: 2
Sample Output in receipts.log file:
Giant Food and Pharmacy
Store #66
Transaction Date: Feb 26, 2013
Cashier Name: Abraham Lincoln
Customer ID: 1
Egg box 3 $7.47
Post Honey Nut Cereal 1 $3.99
Tropicana Orange Juice 2 $8.20
Cashew Nut Can 2 $8.49
Potato 5lb 2 $6.00
---------------------------------
Sub-total $25.66
15% Sale Discount -$3.85
Tax @8% $2.05
---------------------------------
Total $23.86
Giant Food and Pharmacy
Store #66
Transaction Date: Feb 26, 2013
Cashier Name: Abraham Lincoln
Customer ID: 2
Candy Cane 2 $1.00
---------------------------------
Sub-total $1.00
Tax @8% $0.08
---------------------------------
Total $1.08
Explanation / Answer
#include<iostream.h>
#include<time.h>
//simple chasier mechine program
main()
{
cout<<"press(0) to calculate total price ";
q:
float price,total,payment,balance,quantity;
char date [9];
char time [9];
_strdate(date);
_strtime(time);
cout<<"The current date is "<<date<<endl;
cout<<"The current time is "<<time<<endl;
cout<<" ................................. ";
cout<<"......................................................... ";
cout<<": Welcome toSuperMarket : ";
cout<<"......................................................... ";
cout<<" ................................. ";
quantity=0;
total =0;
do{
quantity=quantity+1;
cout<<" Price for"<<quantity<<"item is : RM";
cin>>price;
total = total+price;}
while(price!=0);
cout<<" Total Price "<<" _________________________________________ ";
cout<<" RM"<<total<<endl;
cout<<" _________________________________________"<<endl;
cout<<" Customer payment RM";
cin>>payment;balance=payment-total;
cout<<" Balance = RM"<<balance<<endl;
cout<<" ~THANK YOU~"<<endl;
char y;
cout<<"Would you like to serve for the next customer?(y/n)";
cin>>y;
if (y == 'y'%uE000%uE000y=='1')
{cout<<"************************************************************* ";
cout<<"************************************************************* ";
cout<<""<<endl;
goto q;}
else
{cout<<" ********************** ";
cout<<" * well done ^_^ * ";
cout<<" *take a good rest ya~* ";
cout<<" **********************"<<endl;
return 0;}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.