Coin Change

I have a current assignment for C++ involving us to make a program to determine coin change for example if you input the number 127 you would need 2 half dollars 1quarter and 2 pennies I have no way how to program this tho any help would be awesome.

This is my code that doesn't do what i want it to

#include <iostream>

using namespace std;

int main ( )
{
float change;
int half_dollars, quarters, dimes, nickels, pennies; // declare variables
cout <<"Enter the amount of money: ";
cin >> change; // input the amount of change
half_dollars = change / 50 // calculate half dollars
change= change%50
quarters = change / 25; // calculate the number of quarters
change = change % 25; // calculate remaining change needed
dimes = change / 10; // calculate the number of dimes
change = change % 10; // calculate remaining change needed
nickels = change / 5; // calculate the number of nickels
pennies = change % 5; // calculate pennies

cout << "\nQuarters: " << quarters << endl; // display # of quarters
cout << " Dimes: " << dimes << endl; // display # of dimes
cout << " Nickels: " << nickels << endl; // display # of nickels
cout <<" Pennies: " << pennies << endl; // display # of pennies
system("Pause");
return (0);
}
You're missing a few semicolons and you can't perform modulo operations on floats.
Topic archived. No new replies allowed.