/********************************************************************* * * Description: This program compares the given phone bill * with Aunt Nellie's check. It will state if the * funds are unsufficient or what Aunt Nellie's change * should be in dollars, quarters, dimes, nickels, * and pennies. * * Input: Amount of phone bill and amount of * Aunt Nellie's check. * * Output: States that funds are insufficient, or breaks down * Aunt Nellie's change. * **********************************************************************/ #include #include main() { int dollars, quarters, dimes, nickels, pennies, intchange; float phone_bill, check, change; printf("Enter the amount of your phone bill.\n"); /** user prompt **/ scanf("%f", &phone_bill); printf("[%7.2f]\n", phone_bill); printf("Enter the amount of Aunt Nellie's check.\n"); /** prompt **/ scanf("%f", &check); printf("[%7.2f]\n",check); if(phone_bill>check) /** compares bill to check **/ {printf("The check was insufficient to pay the phone bill.\n"); printf("Don't go home!\n"); printf("The check is for $%7.2f \n", check); printf("and the phone bill is $%7.2f.\n", phone_bill); } else { printf("The phone bill is %7.2f, the check is %7.2f.\n", phone_bill, check); change=check-phone_bill; /** if check is enough, **/ /** determines change **/ intchange=(int)(change*100); dollars=intchange/100; intchange=intchange-dollars*100; quarters=intchange/25; intchange=intchange-quarters*25; dimes=intchange/10; intchange=intchange-dimes*10; nickels=intchange/5; intchange=intchange-nickels*5; pennies=intchange; /** prints out change breakdown **/ printf("The amount due Aunt Nellie is $%7.2f\n", change); printf("made up of %d dollars,\n", dollars); printf("%d quarters, %d dimes,\n", quarters, dimes); printf("%d nickels, and %d pennies.\n", nickels, pennies);} }