You are to write a program that will handle a cash register keeping up with sale
ID: 3540081 • Letter: Y
Question
You are to write a program that will handle a cash register keeping up with sales, payment, change and a running total of cash in the cash register. The cash register will start with 100.00 in cash. You will input a purchase price and a payment where the payment will be either cash (C) or check (k). You will keep up with how much money is brought in for cash and for checks (two accumulators). You will generate a report that shows the purchase price, payment type, payment amount, and change returned if any. You will also show the current cash that is in the cash register. This is for when the boss comes in, he can check the report and check the register and see if the values are in sink.
Your input file for this program is CashReg Receipts.txt . You will write this program using a class. This class will have a constructor method along with the other methods needed to solve this problem.
Output in table form, lined up nice and neat.
Example input: 24.00 C 25.00 -> 24.00 purchase, payment cash, paid 25.00
23.50 K 25.00 -> check
Output Purchase Cash Check Payment Change Cash NRegister
24.00 X 25.00 1.00 124.00
23.50 X 25.00 1.50 147.50
Cash Register Total checks Total cash in Total intake of funds.
Input:
Explanation / Answer
Hi ,
Please use this following code. It is working on my system perfectly . Hope it Helps :)
At the end of the program, I have used the following to calculate Cash Register Total checks Total cash in Total intake of funds. ----- I assumed CashRegister is the total amunt we have, total checks is the count of transactions by cheque, total cash in is count of cash transactions and total intake is (total amount - initial 100 )
If these formulas are not what you expected, please change the last but one line. :)
#include<iostream.h>
#include<fstream.h>
#include<conio.h>
void main()
{
clrscr();
double startingCash =100;
char STRING[300];
double v1=0;
char v2=' ';
double v3=0;
ifstream infile;
infile.open ("input.txt");
double diff;
double totalCash;
int totalCheques=0;
int totalCashIn=0;
cout << "Purchase Cash Cheque Payment Change CashInregister ";
while(infile>> v1 >> v2 >> v3)
{
if(v2=='C')
{
startingCash = startingCash + v1;
cout<<v1<<" "<<"X"<<" "<<v3<<" "<<(v3-v1)<<" "<<startingCash<<" ";
totalCashIn = totalCashIn+1;
}
else
{
startingCash = startingCash + v1;
cout<<v1<<" "<<" "<<"X "<<v3<<" "<<(v3-v1)<<" "<<startingCash<<" ";
totalCheques= totalCheques+1;
}
}
infile.close();
cout<<"-------------------------------------------------------------- ";
cout<<"Cash register Total Cheques Total Cash In Total Intake ";
cout<<startingCash<<" "<<totalCheques<<" "<<totalCashIn<<" "<<(startingCash-100);
getch();
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.