Cash Register/Billing Program

  • (2 Pages)
  • +
  • 1
  • 2

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

#16 jimblumberg   User is offline

  • member icon

Reputation: 5771
  • View blog
  • Posts: 17,672
  • Joined: 25-December 09

Re: Cash Register/Billing Program

Posted 13 November 2019 - 03:02 PM

How about just moving line 5 to before line 3 (but still within the loop)?

Jim
Was This Post Helpful? 0
  • +
  • -

#17 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 - 03:16 PM

View Postmodi123_1, on 13 November 2019 - 02:55 PM, said:

Mkay then I guess I don't understand post 12's input and what you are getting as output.

This is my code and here is the output.
Enter the amount Tendered: $49
You need to still pay $0.61
Enter the amount Tendered: $1
You need to still pay $-0.39 ***How do I get rid of this?
Your change is $0.39
double cash;
do
{
cout<<"Enter the amount Tendered: $";cin >>cash;
total= total-cash;
cout<<"You need to still pay $"<<total<<endl;
}
while (total>0);
double change=total*-1;
cout<<"Your change is $"<<change<<endl;
exit(0);
}


Was This Post Helpful? 0
  • +
  • -

#18 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15362
  • View blog
  • Posts: 61,611
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 03:29 PM

Don't make it a do-while. Make it a while.
Was This Post Helpful? 0
  • +
  • -

#19 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 - 03:30 PM

Tried that as well it still shows.

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

Was This Post Helpful? 0
  • +
  • -

#20 jimblumberg   User is offline

  • member icon

Reputation: 5771
  • View blog
  • Posts: 17,672
  • Joined: 25-December 09

Re: Cash Register/Billing Program

Posted 13 November 2019 - 03:37 PM

Show your properly formatted code and tell us exactly where it "shows".

Oh and what does "Tried that as well it still shows." really mean? You really need to start describing your problem in much more detail and it would be much better if you provided a small complete program instead of a bunch of meaningless snippets.


Jim
Was This Post Helpful? 0
  • +
  • -

#21 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 - 03:45 PM

This is my code below and here is the output.
Enter the amount Tendered: $49
You need to still pay $0.61
Enter the amount Tendered: $1
You need to still pay $-0.39 ***How do I get rid of this? I tried a while loop and it doesn't make a difference
Your change is $0.39

cout.precision(2); cout<<"Your total paint cost plus HST 13% tax is: $"<<total<<"\n"<<endl;//Printing out total cost with HST

double cash;
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:39 PM
Reason for edit:: Removed unnecessary code. No need to quote the post above yours.

Was This Post Helpful? 0
  • +
  • -

#22 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15362
  • View blog
  • Posts: 61,611
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 03:52 PM

you can sink an if statement round 8.
Was This Post Helpful? 0
  • +
  • -

#23 jimblumberg   User is offline

  • member icon

Reputation: 5771
  • View blog
  • Posts: 17,672
  • Joined: 25-December 09

Re: Cash Register/Billing Program

Posted 13 November 2019 - 03:53 PM

You need to move the line "You need to still pay $" to the beginning of the loop instead of the end of the loop.

By the way that is not properly formatted code, it is just one big jumble. And it is also not a small complete program.

You need to find and use a "sane" indentation style, it will make your code much easier to read. And no indentation is not a "sane" indentation style.


Jim
Was This Post Helpful? 0
  • +
  • -

#24 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 - 03:59 PM

View Postmodi123_1, on 13 November 2019 - 03:52 PM, said:

you can sink an if statement round 8.

Thanks so much for helping me this took way to long for one if-statement it worked now.

View Postjimblumberg, on 13 November 2019 - 03:53 PM, said:

You need to move the line "You need to still pay $" to the beginning of the loop instead of the end of the loop.

By the way that is not properly formatted code, it is just one big jumble. And it is also not a small complete program.

You need to find and use a "sane" indentation style, it will make your code much easier to read. And no indentation is not a "sane" indentation style.


Jim

My whole code is composed of one main and three classes I don't think I will be able to put everything so that is why I put a snip of code in which the problem was occurring.
Was This Post Helpful? 0
  • +
  • -

#25 modi123_1   User is online

  • Suitor #2
  • member icon



Reputation: 15362
  • View blog
  • Posts: 61,611
  • Joined: 12-June 08

Re: Cash Register/Billing Program

Posted 13 November 2019 - 04:00 PM

It's a crutch which could be avoided by listening to jim's comment.

Think about it.. if the user is already dropping into that while loop body that means they need to pay, and you can tell them that.. then ask for the amount.. then do the math.. and then the loop turns over to evaluate.
Was This Post Helpful? 0
  • +
  • -

#26 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 - 04:18 PM

I had to structure it the way I did for my assignment as our teacher told us the output should look like his we had to make a replica basically

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

Was This Post Helpful? 0
  • +
  • -

#27 Skydiver   User is offline

  • Code herder
  • member icon

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

Re: Cash Register/Billing Program

Posted 13 November 2019 - 05:47 PM

Qj_Warrior: There is no need to quote the post above yours. Just use the big Reply button or the Fast Reply area.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2