I need Help with this homework?

This is a discussion on I need Help with this homework? within the C++ Programming forums, part of the General Programming Boards category; Help. can anyone make this work correctly. It suppose to ask for amount due, then payment is made and it ...

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

    I need Help with this homework?

    Help. can anyone make this work correctly. It suppose to ask for amount due, then payment is made and it should tell how much change is due in dollars, quarters, dimes, nickles and pennies
    Code:
    #include <iostream>
    using namespace std;
    
    int main()
    {
    int owe = 0.0;
    int paid = 0.0;
    int change = 0.0;
    int dollar = 0 ;
    int quarter = 0 ;
    int dime = 0 ;
    int nickle = 0;
    int penny = 0;
    
    //enter input items
    cout << "Enter Amount Owed: " ;
    cin >> owe;
    cout << "Enter Amount Paid: " ;
    cin >> paid;
    
    
    //calculate total owed in change
    change = paid - owe;
    dollar = change / 1;
    quarter = (change - dollar) / .25;
    dime = (change - dollar - (quarter * .25)) / .1;
    nickle = (change - dollar - (quarter * .25) - (dime * .1)) / .05;
    penny = (change - dollar - (quarter * .25) - (dime * .1) - (nickle * .05))
    / .01;
    
    //display output items
    cout << "change: " << change << endl;
    cout << "dollar(s): " << dollar << endl;
    cout << "quarter(s): " << quarter << endl;
    cout << "dime(s): " << dime << endl;
    cout << "nickel(s): " << nickle << endl;
    cout << "penny(s): " << penny << endl;
    
    return 0;
    }

  2. #2
    Registered User
    Join Date
    Apr 2010
    Posts
    11
    Int = Integers which are whole numbers

    Which of those do you need the number to be a whole number and which do you need to make it have decimals.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. help about homework
    By agathery in forum C Programming
    Replies: 27
    Last Post: 05-19-2010, 10:17 PM
  2. Homework
    By kermi3 in forum C Programming
    Replies: 10
    Last Post: 09-27-2001, 05:49 PM
  3. Homework
    By kermi3 in forum Windows Programming
    Replies: 5
    Last Post: 09-15-2001, 12:48 PM
  4. Homework
    By kermi3 in forum C Programming
    Replies: 0
    Last Post: 09-10-2001, 02:26 PM

Tags for this Thread


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