This is my code so far:
I have been having a lot of trouble with this one. I am trying to prompt the user for an amount of change, then determine how many quarters, nickels, dimes, and pennies the entered amount would make. I may have been staring at this for too long the longer I look at this the worse my code becomes. Any help would be greatly appreciated..Code:#include <iostream> using namespace std; int main(){ int cent; int quarter = 25; int dime = 10; int nickel = 5; int penny = 1; cout << "Enter an amount in cents: "; cin >> cent; cout << "The amount you entered is: " << cent << " cents\n"; cout << endl; //This is where I am getting lost if (cent % quarter) cout << "Quarters: " << cent << endl; if (cent % dime) cout << "Dimes: " << cent << endl; if (cent % nickel) cout << "Nickels: " << cent << endl; if (cent % penny) cout << "Pennies: " << cent << endl; system("pause"); return 0; }



LinkBack URL
About LinkBacks



