Change maker program remainder troubles.
I have to make a program into which the user enters their bill in a decimal number and the remainder is broken down into dollars, quarters, dimes, nickels and pennies. I learned how to use setprecision(x). Here's my code:
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);
}
How do I use % to narrow it down? I'm stuck. :[