OK here is my entire program. I still don't have this figured out. The first time I input for example 50, it says that the ATM can't make cash out of it. But when it prompts again I put in 50 and it works.
I need for the ATM to accept any cash requests that are divisible by 10.
Code:
#include<stdio.h>
#include<math.h>
#define PIN 2424
#define TRUE 1
/* Function Prototypes */
void bank_logo(void);
void validate_pin(void);
int get_data(int money);
int main(void)
{
double open_bal;
int cash;
int new_cash;
int money;
bank_logo();
validate_pin();
printf("Enter the opening balance of your account $");
scanf("%lf", &open_bal);
printf("Enter how much cash you need? $");
scanf("%d", &cash);
printf("new cash %d", get_data(new_cash));
return(0);
}
void bank_logo(void)
{
printf("$$$$$$$$$$$$$$$$$$$$$$$$$$\n");
printf("$ $\n");
printf("$ BankOne Money Access $\n");
printf("$ $\n");
printf("$ 24 hours $\n");
printf("$ 7 days a week $\n");
printf("$ All year long!!! $\n");
printf("$ $\n");
printf("$$$$$$$$$$$$$$$$$$$$$$$$$$\n\n\n");
}
void validate_pin(void)
{
int id; /* input of user's PIN number */
int count;
for (count = 0; count < 3; ++count){
printf("Enter your 4-digit personal identification (PIN) >> ");
scanf("%d", &id);
if (id != PIN)
printf("Sorry! Invalid PIN number !\n");
else
break;
}
if (count == 3)
printf("\nYour chances are up. Better luck next time.\n\n");
}
int get_data(int money)
{
while( TRUE )
{
/* test but dont change money */
if(money % 10 == 0)
{
return money;
}else{
printf("\n\nThis machine dispenses ONLY $50, $20, $10...\n\n");
printf("Please enter again:> ");
scanf("%d", &money);
}
}
}