I have this much compliled and running, but I am stuck on how to place a validation step in the event the user inputs something not within the required input ($10 denominations). For instance if I input 35 I wil get back one 20 and 1 10. I would like to be able to tell the user that ther input was invalid please reenter desired amount.
Code:
* This program will take input from the user of an ATM and provide the user with the number
* of $50, $20 and $10 dollar bills the ATM will dispense based on the user's input. It will
* also prompt the user to reenter their amountif they have entered it incorrectly.*/
#include <stdio.h>
void bills_dispensed (int amount_entered)
{
int amount_remaining; /* Holds on to the amount_remaining amount through each step of the calculations. */
printf("\nYour amount of %d dollars is dispensed as follows.\n", amount_entered);
/* Compute the total number of 50 dollar bills in the amount. */
printf("50 dollar bills : %d\n", (amount_entered/50));
/* Compute amount_remaining to be dispensed after dispensing 50 dollar bills. */
amount_remaining = (amount_entered%50);
printf("20 dollar bills : %d\n", (amount_remaining/20));
amount_remaining = (amount_remaining%20);
printf("10 dollar bills : %d\n", (amount_remaining/10));
}
int main ()
{
int amount_entered;
printf("**************************************\n");
printf("** Welcome to your neighborhood ATM **\n");
printf("**************************************\n\n");
printf("This ATM will only distribute $50, $20 and $10 denominations.\n\n");
printf("Please enter the amount (multiple of 10 dollars)you wish to withdraw :$ ");
scanf("%d", &amount_entered);
bills_dispensed(amount_entered);
return 0;
}