DOLLAR GAME

change for a dollar game. so basically you input the number of coins you have for pennies, nickels, dimes and quarters which has to add to a dollar

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
float pennies = .1, nickels = .5,dimes = .10, quarters = .25;
    float dollar = 1.00;
    int totalamount;
    
    cout << " please enter the number of change for\n";
    cout << "pennies, dimes , nickels, quarters\n";
    cout << "that will sum up to a dollar";
    cin >> pennies >> dimes >> nickels >> quarters;
    
    totalamount = pennies + dimes + nickels + quarters;
    
    if ( totalamount == dollar)
    {
        cout << "congratulations that equals a dollar!\n";
    }
    else
    {
        cout << "sorry that does not equal one dollar\n";
    }
    .

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
int main()
{
    float pennies, nickels, dimes, quarters ; // the cin sets the values of the variables 
    float dollar = 1.00 ;
    int totalamount ;

    cout << " please enter the number of change for\n" ;
    cout << "pennies, dimes, nickels, quarters\n" ;
    cout << "that will sum up to a dollar" ;
    cin >> pennies >> dimes >> nickels >> quarters ; // 

    totalamount = (pennies * .01)+(nickels * .05)+(dimes * .10)+(quarters * .25) ; // the variables are set to how many there are not how much there worth                                                                                                        
    if (totalamount == dollar) //also could get rid of dollar variable and put just 1.00 here or even just 1
    {
        cout << "congratulations that equals a dollar!\n" ;
    }
    else
    {
        cout << "sorry that does not equal one dollar\n" ;
    }
}

Do you mean to generate every possible combination?
no just something simple. im not trying to go over the top with the program.
@shadowcode56 thanks man i appreciate the help
Topic archived. No new replies allowed.