HELP!!!

I have a problem with my program and i cant seem to fix it
could some one help me out


Hears My Program:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#include<iostream>
using namespace std;
int main(){

    double Money = 0.00;
    int Money1;
    int quarters;
    int dimes;
    int nickels;
    int pennies;
    
    cout <<"                         Welcome to Dollars to coins " << endl;
    cout <<" Type in amount: ";
    cin  >> Money;
    Money       = Money * 100;
    Money1      = Money;
    quarters    = Money1/25;
    dimes       = 10/(Money1 - quarters * 25);
    nickels     = 5/(Money1 - dimes * 10);
    pennies     = 1/(Money1 - nickels * 5);
       
       cout <<" quarters " << quarters <<" dimes " << dimes <<" nickels " 
     << nickels <<" pennies " << pennies << endl;
    system("PAUSE");
    return 0;
}
                 


it is giving a random value for Money1
and when i try to declare it a error accers

Last edited on
The line
Moneyl = Moneyl;
needs to be replaced with
Moneyl = Money;
so that you are not just trying to assign that variable the value it already had.
Also, you it looks like you'll need to fix how you calculate nickels and pennies because it doesn't take into account all previous coins. You could try something like
Moneyl -= quarters * 25
to make finding all of your other coins easier.
Last edited on
i get the first part which i never ment to put in there in the first place
but i dont really get the second port were am i spo to put it and what is it solving for
What I was trying to say is that the line where you calculate nickels only takes account of the dimes, not the quarters. The easiest way to take care of this would be to just take each value out of money1 as you find it. Here's what I mean:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#include<iostream>
using namespace std;
int main(){

    double Money = 0.00;
    int Money1;
    int quarters;
    int dimes;
    int nickels;
    int pennies;
    
    cout <<"                         Welcome to Dollars to coins " << endl;
    cout <<" Type in amount: ";
    cin  >> Money;
    Money       = Money * 100;
    Money1      = Money;
    quarters    = Money1 / 25;     // Find quarters
    Money1 -= quarters * 25;      // Remove quarters
    dimes       = Money1 / 10       // Repeat with other coins...
    Money1 -= dimes * 10;
    nickels     = Money1 / 5;
    Money1 -= nickels * 5;
    pennies     = Money1;
       
       cout <<" quarters " << quarters <<" dimes " << dimes <<" nickels " 
     << nickels <<" pennies " << pennies << endl;
    system("PAUSE");
    return 0;
}

Each line here takes out the value of the coins the program found. The extra lines then remove the value of those each coin by subtracting from the total value the number of coins multiplied by each coin's appropriate value.
yeah it still dosent work but i found a diffrent way to do it
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
#include<iostream>
using namespace std;

int main(){
    float Money = 0.00;
    int Money1 = 0000;
    int Pennies = 00000;
    int Nickles = 000;
    int Dimes = 00;
    int Quarters = 0; 
    cout << "                 Welcome to the Money Counter " << endl;
    
    cout << "Type in the amount: ";
    cin  >> Money;
              Money = Money * 100;
              Money1= Money;
    cout << endl << endl << endl;
    if(Money1 >= 25){
              Quarters = (Money1/25);
              Money1   = Money1 - (25*Quarters)  ;
              }
    if(Money1 < 25 && Money1 >= 10){
              Dimes   = (Money1/10);
              Money1  = Money1 - (10 * Dimes);
              }
    if(Money1 < 10 && Money1 >= 5){
              Nickles   = (Money1/5);
              Money1  = Money1 - (5 * Nickles);
              }
    if(Money1 < 5 && Money1 >= 1){
              Pennies = Money1;
              }
    cout << " That is " << Quarters << " Quarters " << Dimes << " Dimes " << Nickles <<
     " Nickles " << Pennies << " Pennies " << endl;
    system("PAUSE");
    return 0;
}




This one gets a warning when i change int to float but it works just fine
The program i use dosent like the - sigh before the equals sigh
thanks any way
Last edited on
Topic archived. No new replies allowed.