Hi,
I'm working onn an assignment and I'm stuck! Maybe it's because I'm still new at programming but I can't get my program to exit after you enter 'N' for no when the user is asked "Do you want to try again?", it just starts over as if I had typed in 'Y'.
Also can someone tell me if it's possible to empty the memory so that the coins don't add up after each try?
Any help would be great I've spent hours trying to fix this on my own!
thanks,
here is the relavent code.
Code:
while(ch='Y'){
printf("\n Your total is $", amount);
scanf(" %f", &amount);
change=(5.00-amount);
while(change>=0 && change<=500){
.....(enclosed while statements, I checked the curly brackets!)
// print results
printf(" You have %d coins of 2 dollars \n", toonie);
printf(" You have %d coins of 1 dollar \n", dollar);
printf(" You have %d coins of 25 cents \n", quarter);
printf(" You have %d coins of 10 cents \n", dime);
printf(" You have %d coins of 5 cents \n", nickel);
printf(" You have %d coins of 1 cent \n", cent);
break;
{
printf("\n Do you want to try again? (Y/N)\n");
ch=toupper(getche());
printf("\n");
} getch();
}
I tried and tried to fix it without result.