i have some problems that i need help with.

would just putting:

quarter = .25 number % quarter
dime = .1 afterQuarters = number - ( numQuarters*quarter ) afterQuarters % dime
nickel = .05 afterQuarters = number - (numQuarters*quarter) afterQuarters % nickel
penny = .01 afterQuarters = number - (numQuarters*quarer) afterQuarters % penny

in the code work, or do I have to do something to it? That is the formula, and i was tryng to make it work with the code. I do not know if it will just draft in though. maby i have to surround it in other code, i dont know...

Also, i have made the simple 'stilted' way of showing the results. How do you make it 'non-stilted' I have tried many else if statements, but so far i got long confusing else ifs that probably will not work. And the ones that are simple i dont know how to combine them, like here

if (pennies = 0) 
cout << number << 'requires' << quarter << 'quarters,' << dime << 'dimes, and' << nickel << 'nickels' <<endl; 
cout << endl;

else if (pennies < 0)
cout << number << 'requires' << quarter << 'quarters,' << dime << 'dimes,' << nickel << 'nickels, and' << penny <<'pennies'<<endl; 
cout << endl;

If i do that, i dont know how to draft the rest of the money types with it. Do i just do

if (pennies = 0) || (nickels = 0) || (dimes = 0)

etc...? or what?

and when i say stilted, here is an example

58 cents requires 2 quarters, 0 dimes, 1 nickels, 3 cents.

the non tilted way would appear like this

58 cents requires 2 quarters, 1 nickel, 3 cents

>>in the code work, or do I have to do something to it? That is the formula, and i was tryng to make it work with the cod
Yes, you will have to modify it to make them legal c or c++ statements.

First, you have to know the kind of units you will enter -- are you going to start with X number of quarters ? or something else ?

>>if (pennies = 0) || (nickels = 0) || (dimes = 0)
You used the wrong operator, = is an assignment operator, and == is a boolean operator. So it should be if (pennies == 0) || (nickels == 0) || (dimes == 0)

would it be simpler to just post the whole code here, and then describe my problem? because i am still lost...

"First, you have to know the kind of units you will enter -- are you going to start with X number of quarters ? or something else ?"

Umm... I will start off with as many as the user inputs...?

"You used the wrong operator, = is an assignment operator, and == is a boolean operator. So it should be" But would it work to keep the results non-stilted?? or is it useless in this case?

#include <iostream.h>

main()
{
int quarter;
int dime;
int nickel;
int penny;
int number;

cout << "Enter a number. " << endl;
cin >> number;

quarter = .25 number % quarter
dime = .1 afterQuarters = number - ( numQuarters*quarter ) afterQuarters % dime
nickel =  .05 afterQuarters = number - (numQuarters*quarter) afterQuarters % nickel
penny = .01 afterQuarters = number - (numQuarters*quarer) afterQuarters % penny
cout << number << "requires" << quarter << "quarters," << dime << "dimes," << nickel << "nickels, and" << penny <<"pennies"<<endl; 
cout << endl;

system("PAUSE");
return 0;

would it be simpler to just post the whole code here, and then describe my problem? because i am still lost...

"First, you have to know the kind of units you will enter -- are you going to start with X number of quarters ? or something else ?"

Umm... I will start off with as many as the user inputs...?

"You used the wrong operator, = is an assignment operator, and == is a boolean operator. So it should be" But would it work to keep the results non-stilted?? or is it useless in this case?

I imagine you want this line:

quarter = .25 number % quarter

to be something like:

quarter = number / 0.25;

If you have $1.78, you'll have 7 quarters, which is 1.78/0.25 (integer division truncates to 7). I don't think you want to % operator at all and you want to divide, not multiply, right? I assume quarter represents the NUMBER of quarters, not the VALUE of the quarters, correct? Also, if you are entering dollars and cents, number should be a double, not an int, or do you enter the number of pennies? If that's the case, keep it as an int and divide by 25 rather than 0.25 above.

I imagine you want this line:

quarter = .25 number % quarter

to be something like:

quarter = number / 0.25;

If you have $1.78, you'll have 7 quarters, which is 1.78/0.25 (integer division truncates to 7). I don't think you want to % operator at all and you want to divide, not multiply, right? I assume quarter represents the NUMBER of quarters, not the VALUE of the quarters, correct? Also, if you are entering dollars and cents, number should be a double, not an int, or do you enter the number of pennies? If that's the case, keep it as an int and divide by 25 rather than 0.25 above.

If here were converting a particular number to a different type (say making 100 dollars equal to n amount quarters OR n amount dimes OR) then I'd wholeheartedly agree.

I think he was trying to find the remaining amount of cash after the highest amount of money (without a remainer) was determined.

For example, 2.12 dollars is equal to 8 quarters, 1 dime and 2 pennies. I think his algorithm took care of that (at least with the rules of PEMDAS, and possibly not the rules of programming arithmetic).

cout << "Enter a number. " << endl;
cin >> number;

Enter the number of what? Are you supposed to enter the number of quarters, or the number of dimes, or the number of whole dollars ? or what? Since number is an integer you can't enter something like $1.25 because integers don't have fractions, they are only whole numbers. So if you want number to be the number of quarters then you would have to enter 5, which is 5 quarters = $1.25. If you want number to be the number of nickels then you would have to enter 25 because there are 25 nickles in 1.25.

If here were converting a particular number to a different type (say making 100 dollars equal to n amount quarters OR n amount dimes OR) then I'd wholeheartedly agree.

I think he was trying to find the remaining amount of cash after the highest amount of money (without a remainer) was determined.

For example, 2.12 dollars is equal to 8 quarters, 1 dime and 2 pennies. I think his algorithm took care of that (at least with the rules of PEMDAS, and possibly not the rules of programming arithmetic).

$2.12 / $0.25 would equal 8, so you have $0.25 * 8 = $2.00 in quarters, so for the next step, subtract $2.00 from $2.12 and get $0.12. At this point you figure out how many dimes by dividing $0.12 by $0.10. I was only commenting on the first step in my last post.

If we're dealing with the number in pennies, the mod could come in with:

number = number % 25;

which, if number == 212, would give you 12, which is the amount left over after the quarters are taken out. You could do that instead of subtracting 212-200.

I don't know how this one works at all, even from a mathematical, non-C++ standpoint.

quarter = .25 number % quarter

This is performing modular arithmetic on a variable, and an uninitialized one at that, and I don't see how doing a multiplication or a mod gets you the number of quarters.

[EDIT]
I just reread your last post a little more carefully and it goes along with what I had posted earlier. The OP needs to explicitly define what the variable quarter represents to avoid confusion. Is it the number of quarters or the value or the amount left over or what?
[/EDIT]

cout << "Enter a number. " << endl;
cin >> number;

Enter the number of what? Are you supposed to enter the number of quarters, or the number of dimes, or the number of whole dollars ? or what? Since number is an integer you can't enter something like $1.25 because integers don't have fractions, they are only whole numbers. So if you want number to be the number of quarters then you would have to enter 5, which is 5 quarters = $1.25. If you want number to be the number of nickels then you would have to enter 25 because there are 25 nickles in 1.25.

By enter number, i meant enter total given. I should of made it clear in the code, i know.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.