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;

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

Topic archived. No new replies allowed.