OK here is what I have so far.
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 get_balance(double balance, int bal_cash);
void fifties_twenties_tens(int tot_bal, int *fifty, int *twenty, int *ten);
int main(void)
{
double open_bal;
int cash;
int new_cash;
int money;
int balance_cash;
int fif;
int twen;
int tens;
int remaining_balance;
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);
balance_cash = get_data(cash);
printf("\nThe amount you are withdrawing = %d\n", balance_cash);
remaining_balance = get_balance(open_bal, balance_cash);
printf("Remaining Balance in your account = %d\n\n", remaining_balance);
printf(" *** Take your cash as $$$ bills *** \n\n");
fifties_twenties_tens(balance_cash, &fif, &twen, &tens);
printf(" %5d fifty %5d twenties and %5d tens\n\n", fif, twen, tens);
/*
printf(" %5d fifty %5d twenties and %5d tens", fifties_twenties_tens(balance_cash, &fif, &twen, &tens);
*/
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 if (count == 3)
printf("\nYour chances are up. Better luck next time.\n\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);
}
}
}
int get_balance(double balance, int bal_cash)
{
double final_bal;
final_bal = balance - bal_cash;
return final_bal;
}
void fifties_twenties_tens(int tot_bal, int *fifty, int *twenty, int *ten)
{
*fifty = tot_bal / 50;
int rem_twenty = tot_bal % 50;
*twenty = rem_twenty / 20;
int rem_ten = rem_twenty % 20;
*ten = rem_ten / 10;
/*
*fifty = 50;
*twenty = 20;
*ten = 10;
*/
}
and here is a sample output so far
Code:
Enter your 4-digit personal identification (PIN) >> 2424
Enter the opening balance of your account $500
Enter how much cash you need? $60
The amount you are withdrawing = 60
Remaining Balance in your account = 440
*** Take your cash as $$$ bills ***
1 fifty 0 twenties and 1 tens
What I want to do now is to make a loop so that it asks if the user wants another transaction, and if they enter yes, it should ask how much cash they need. And then to subtract that from the remaining balance (In the example would be 440). And that at the end I want it to print out how many transactions there were.
Any help is appreciated and thanks in advance!