change for a dollar game

i need help. is my code correct? and is there anything i can do to improve it?
float pennies, nickels, dimes, quarters;
float total,sum;

cout << "please enter the number of\n"
"pennies,nickels,dimes and quarters\n"
"uses spaces in between numbers"<<endl;
cin>> pennies >> nickels>>dimes>>quarters;

sum = (pennies)+(nickels *5)+(dimes*10) + (quarters *25);



if (total == 1.00)
cout << "congratulations"<<endl;
else if (total >1.00)
cout << "too much"<<endl;
else if (total < 1.00)
cout << "try again"<<endl;


Last edited on
Use int for variable type, You cant have half a penny etc...
Topic archived. No new replies allowed.