Cash register program? I'm lost

This is a discussion on Cash register program? I'm lost within the C++ Programming forums, part of the General Programming Boards category; I am totally new to programming and I'm feeling like an idiot. I need to write a c++ program, basically ...

  1. #1
    Registered User
    Join Date
    Oct 2011
    Posts
    1

    Cash register program? I'm lost

    I am totally new to programming and I'm feeling like an idiot. I need to write a c++ program, basically a cash register program is what I've been told it's commonly called. It needs to ask for amount owed, amount paid, and display the change and break the change down into dollars,quarters,dimes,nickels,pennies. If the amount paid is less then the amount owed it needs to display a message saying the customer owes whatever the difference is. I'm supposed to use a "nested if" here is what I have so far :
    Code:
    #include<iostream>
    #include<iomanip>
    
    using namespace std;
    
    int main()
    
    {
    float a,b,c;
        cout<<"Enter amount owed $ : ";
            cin>>a;
        cout<<"Enter amount paid $ : ";
            cin>>b;
            c=a-b;
        cout<<"Your change is $ : ";
    
        if (c>=0)
        {    cout<<"You owe $ : ";
        cout<<c*-1;
        }
        
    cout<<fixed;
      cout<<setprecision(2);
      cout<< c;
    
    
      cout << endl << endl;
      system("pause");
      return 0;
            
    }
    And this is where I become totally lost, I don't really get how to break the change down. I'm not sure how to actually write the nested if.

  2. #2
    Registered User
    Join Date
    Oct 2011
    Posts
    10
    Use modulus...im not sure how to spell it but it is an arithmetic symbol that looks like this. % .
    Which gives the remainder of a number divided by a number. Hope that helps a little bit

  3. #3
    Registered User
    Join Date
    May 2010
    Posts
    2,900
    I'm supposed to use a "nested if" here is what I have so far :
    You may want to study this link: Control Structures and then actually try to solve the problem.
    And this is where I become totally lost, I don't really get how to break the change down.
    You may to first turn off your computer, and try a few examples of making change the old fashioned way with pencil and paper. Once you know how to manually make change transfer that knowledge into a computer program.

    Use modulus...im not sure how to spell it but it is an arithmetic symbol that looks like this. % .
    The modulus operator % will not work with floating point numbers.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help me fix one problem with my cash register
    By lil_rom in forum C Programming
    Replies: 3
    Last Post: 04-14-2008, 01:03 AM
  2. help me fix one problem with my cash register
    By lil_rom in forum C++ Programming
    Replies: 4
    Last Post: 04-13-2008, 03:15 PM
  3. Help fixing my cash register program.
    By lil_rom in forum C++ Programming
    Replies: 5
    Last Post: 04-11-2008, 03:28 PM
  4. Cash register program help :(
    By lil_rom in forum C Programming
    Replies: 2
    Last Post: 04-11-2008, 01:35 AM
  5. Cash Register
    By Hursh in forum C Programming
    Replies: 5
    Last Post: 01-22-2002, 03:36 AM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21