# Change Maker (problems with %)

• 03-07-2011
muffinman8641
Change Maker (problems with %)
OK, so for school, I have to make a program that illustrates the change a person should get based on a few monetary inputs. I'm crafting one that does so in the following steps:

1. User inputs monetary value (e.g. 17.34 for \$17.34) describing the original bill.

2. User inputs monetary value describing how much cash they paid.

3a. If the amount paid is less than the bill, it tells you that you still owe the difference (which is produced).

3b. If the amount paid is more than the bill, it illustrates the most efficient change you should get, in dollars, quarters, dimes, nickels, and pennies.

3b is where I'm stuck. I know that inputting, for example, (25 % 3) would return the remainder of 25 / 3, which is 1. However, I want to divide, say, 25 by 3, return the 8, and keep the one to work with in the next step.

This is confusing me. D:

Oh yeah, here's my code so far (don't yell at me for the goto, I only used it once. Feel free to toss a way to not use it my way, though.)

Code:

``` #include <iostream> #include <iomanip> using namespace std; int main() {     double bill, paid, dollars, quarters, dimes, nickels, pennies, remaindol = (paid - bill);     cout << "Welcome to my change-maker program! " << endl;     cout << "To begin, press ENTER. " << endl;     getchar();         restart:         cout << "\n\nEnter how much the bill is. " << endl;     cout << "Do not use a \$ sign. Just enter the decimal number. " << endl;     cin >> bill;     cout << "Now enter how much cash you paid. " << endl;     cin >> paid;     if (paid < bill) {             cout << "Uh-oh! You need to pay more cash. You " << endl;             cout << "haven't paid the whole bill yet. " << endl;             cout << "You still owe " << setprecision(2) << fixed << (bill - paid) << ". " << endl;             goto restart;             }         if (bill <= paid) {             cout << "You should get " << (paid - bill) << " in change. " << endl;             cout << "The most efficient way to get your " << (paid - bill) << " would " << endl;             cout << "be to get: " << endl;                         //need to fit in change. narrow down. } getchar(); return (0); }```
• 03-08-2011
muffinman8641
OK I have it figured out except one thing: how do you make some variables in and some double? CAN you do that?
• 03-08-2011
Mr.777
What do you really mean by to make some variables int and some double???
Code:

```int x,y; double a,b;```
Ain't this???

.......So simple ...
• 03-09-2011
Salem