Cash Register/Billing Program

  • (2 Pages)
  • +
  • 1
  • 2

26 Replies - 684 Views - Last Post: 13 November 2019 - 05:47 PM Rate Topic: -----

#1 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Cash Register/Billing Program

Posted 13 November 2019 - 08:57 AM

Hey there I was wondering if anyone could help me I'm kinda stuck with my billing program currently I Have gotten the total cost with HST all I am having trouble with is adding user input amount tendered like this below:

Enter the amount tendered: $200
You need to pay 455.34 more
Enter the amount tendered: $200
You need to pay 255.34 more
Enter the amount tendered: $300
Your Change due= $44.66

double Receipt::totalval(double a, double b, double c, double d)//Setting the function within a class
{
system("cls");//Clearing the Screen to clear everything before the Recipet prints
cout.setf(ios::fixed);
double t= a+b+c+d;//Calculating Totsl Cost
double total= t*1.13;//Calculating Totsl Cost with Tax.
cout<<"    ___         _                  ___        _         _   "<<endl;//Printing out Recipet Header below
cout<<"   /   \\ _   _ | | _   _ __  __   / _ \\ __ _ (_) _ __  | |_ "<<endl;
cout<<"  / /\\ /| | | || || | | |\\ \\/ /  / /_)// _` || || '_ \\ | __|"<<endl;
cout<<" / /_// | |_| || || |_| | >  <  / ___/| (_| || || | | || |_ "<<endl;
cout<<"/___,'   \\__,_||_| \\__,_|/_/\\_\\ \\/     \\__,_||_||_| |_| \\__|"<<endl;
cout<<"............................................................"<<endl;
cout<<"Thank you for choosing The Dulux Paint Store Mississauga."<<endl;//Printing out Thank you statement
cout<<"Please come again!"<<endl;
cout.precision(2); cout<<"Total cost for Red Paint: $"<<a<<endl;
cout.precision(2); cout<<"Total cost for Green Paint: $"<<b<<endl;
cout.precision(2); cout<<"Total cost for Blue Paint: $"<<c<<endl;
cout.precision(2); cout<<"Total cost for Magenta Paint: $"<<d<<endl;
cout.precision(2); cout<<"Your total paint cost plus HST 13% tax is: $"<<total<<endl;//Printing out total cost with HST



This is what I have got so far.

Is This A Good Question/Topic? 0
  • +

Replies To: Cash Register/Billing Program

#2 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 09:00 AM

I am not following. Is your problem getting user input or running the math in that function?
Was This Post Helpful? 0
  • +
  • -

#3 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7139
  • View blog
  • Posts: 24,247
  • Joined: 05-May 12

Re: Cash Register/Billing Program

Posted 13 November 2019 - 09:05 AM

Okay, all that code you have there is for printing out values, but what you are asking for is about getting values from the user.

We are not a code writing service. We will not do your homework for you.

If you are stuck, tell us exactly how you are stuck. Are you running into a problem with the compiler? Did you decide to skip several lessons, and now that project is due realize that you don't know how to get input? Please go into more detail about what you need help with.
Was This Post Helpful? 0
  • +
  • -

#4 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Re: Cash Register/Billing Program

Posted 13 November 2019 - 09:12 AM

The problem I'm facing is how do I make it so I get user input and then deduct it off the total value how would I code it in c plus plus
for example I have a total of 20
I pay 5 user input
you need to pay 15 dollars more (Compiler)
I pay another 5
you need to pay 10 dollars more (Compiler)
I pay 15
and then the compiler outputs your change is 5 dollars.

View PostSkydiver, on 13 November 2019 - 09:05 AM, said:

If you are stuck, tell us exactly how you are stuck. Are you running into a problem with the compiler? Did you decide to skip several lessons, and now that project is due realize that you don't know how to get input? Please go into more detail about what you need help with.


I know how to do Cin statment the problem i'm facing is how does the compiler know when to provide back change?

Would I have to put it in a loop until it reaches zero?

This post has been edited by Skydiver: 13 November 2019 - 09:26 AM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#5 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7139
  • View blog
  • Posts: 24,247
  • Joined: 05-May 12

Re: Cash Register/Billing Program

Posted 13 November 2019 - 09:28 AM

The compiler doesn't know when to provide back change. You'll need to write code to do this. Yes looping until the total amount tendered is greater than or equal to the bill total. After the loop, if the amount tendered is greater than the bill amount, then you compute the change, otherwise there is no need to provide change.
Was This Post Helpful? 1
  • +
  • -

#6 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Re: Cash Register/Billing Program

Posted 13 November 2019 - 09:54 AM

I'm Almost done I need help with figuring how do I figure out change like what is the equation.

double cash;
if (total>0)
{
Calculate:
cout<<"Enter the amount Tendered: $";cin >>cash;
total= total-cash;
cout<<"You need to still pay $"<<total<<endl;
goto Calculate;
}
else
{
double change=
cout<<"Your Change due is equal to: $"<<change<<endl;
}


Was This Post Helpful? 0
  • +
  • -

#7 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 09:55 AM

Please do not use 'goto' when a proper loop would do.
Was This Post Helpful? 1
  • +
  • -

#8 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Re: Cash Register/Billing Program

Posted 13 November 2019 - 10:01 AM

How would I put this in a proper loop?
Was This Post Helpful? 0
  • +
  • -

#9 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7139
  • View blog
  • Posts: 24,247
  • Joined: 05-May 12

Re: Cash Register/Billing Program

Posted 13 November 2019 - 11:26 AM

You could use a while loop:
while cash < total
    ask for money



or you could use a do-while loop:
do
   ask for money
while cash < total


Was This Post Helpful? 0
  • +
  • -

#10 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Re: Cash Register/Billing Program

Posted 13 November 2019 - 12:15 PM

I have done this so far but I am stuck on how to do change could you help me?
double cash;
while (total>0)
{
cout<<"Enter the amount Tendered: $";cin >>cash;
total= total-cash;
cout<<"You need to still pay $"<<total<<endl;
}
}



This post has been edited by Skydiver: 13 November 2019 - 05:45 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#11 Skydiver   User is offline

  • Code herder
  • member icon

Reputation: 7139
  • View blog
  • Posts: 24,247
  • Joined: 05-May 12

Re: Cash Register/Billing Program

Posted 13 November 2019 - 02:01 PM

If you decide to go down that path, then the loop will naturally terminate when total is zero, or when it is negative. After the loop, check if it is negative. If it is, then that is the amount of change that that you need to give back.
Was This Post Helpful? 0
  • +
  • -

#12 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Re: Cash Register/Billing Program

Posted 13 November 2019 - 02:24 PM

It works but there is a problem so suppose I get change 5 dollars it outputs it but before that it also says you still need to pay -5 dollars how do I fix it?
while (total>0)
{
cout<<"Enter the amount Tendered: $";cin >>cash;
total= total-cash;
cout<<"You need to still pay $"<<total<<endl;
}
double change=total*-1;
cout<<"Your change is $"<<change<<endl;
exit(0);
}


This post has been edited by Skydiver: 13 November 2019 - 05:45 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#13 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 02:27 PM

How about rethinking it to be more realistic.

Only check (don't do the math) on total price - total cash in and if that is less than or equal to 0. If not add more to the cash variable.
Was This Post Helpful? 0
  • +
  • -

#14 Qj_Warrior   User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 12
  • Joined: 13-November 19

Re: Cash Register/Billing Program

Posted 13 November 2019 - 02:40 PM

That is how my teacher wants it to be..

This post has been edited by Skydiver: 13 November 2019 - 05:45 PM
Reason for edit:: Removed unnecessary quote. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#15 modi123_1   User is offline

  • Suitor #2
  • member icon



Reputation: 15361
  • View blog
  • Posts: 61,605
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 02:55 PM

Mkay then I guess I don't understand post 12's input and what you are getting as output.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2