Need help with this hw question

Calculate the exact change (coins) that needs to be given. Program prompts user
to input an integer which represents the total cents (change) that needs to be
distributed. If a negative value is entered, program terminates. Program then
calculates and prints the most efficient combination of quarters, nickels, dimes and pennies.

I was wondering if i could change a code from my previous hw to get the result. The code is the following:

#include <iostream>
using namespace std;
int main () {

int quarter , dime , nickles, cents, total;

cout << "How many quarters do you have " ;
cin >> quarter;
cout << "How many dimes do you have " ;
cin >> dime;
cout << "How many nickles do you have " ;
cin >> nickles;
cout << "How many cents do you have " ;
cin >> cents;

total = quarter * 25 + dime * 10 + nickles * 5 + cents * 1;

cout << "That makes " << total << " in change." << endl;

return 0;
}

please let me know.
Last edited on
closed account (48T7M4Gy)
You could use that as a start, especially modify it as a piece of pseudocode. Your new program automates the answer to each how many question.
Topic archived. No new replies allowed.