Code:
#include <stdio.h>
//************************************************************************************************//
//**********************************************DISPLAY MENU*************************************//
//**********************************************************************************************//
void atm(int accountno, double account_balance )
{
int choice=1;
double amount=0;
double iterator=0;
while(choice!=0){
printf("Hello %d what would you like to do today?\n", accountno);
printf("1 for Account Balance\n");
printf("2 for Cash Deposit\n");
printf("3 for Cash Withdrawal\n");
printf("0 for Exit\n");
printf("Please make your selection >> \n");
scanf("%d",&choice);
//******************************************************************//
if(choice==1){
printf("Your account balance is %.2lf\n\n\n",account_balance);
}
//*****************************************************************//
else if(choice==2)
{
printf("Enter your deposit amount: ");
scanf("%lf",&amount);
if(valid_deposit(amount))
{
account_balance+=amount;
}
else
{
printf("Error:Invalid Deposit Amount!\n\n\n");
}
}
//********************************************************************//
else if(choice==3)
{
printf("Enter your withdraw amount: ");
scanf("%lf" ,&amount);
if(valid_withdrawal(account_balance,amount))
{
account_balance-=amount;
given_money(amount);
}
else
{
printf("Error: Invalid Withdraw Amount!\n\n\n");
}
}
//**********************************************************************//
//*********************************************************************//
else printf("Error:Invalid Choice!\n\n\n");
}
}
//****************************************************************************//
//****************************************************************************//
//************************************************************************************************//
//**************************************FIND ACCOUNT FUNCTION************************************//
//**********************************************************************************************//
int find_account(int accountNums[] , int acctNum , int numAccts)
{
if(accountNums[0]==acctNum||accountNums[1] == acctNum) return 1;
return -1;
}
//**********************************ACCOUNT NAME****************************************//
char accountNames[100] = {"CS111" ,"MUHAMMET"};
if(accountNames=='CS111' || accountNames=='MUHAMMET' )
{
printf("Finding account %d returns %d\n", CS111, find_account(accountNames,CS111,2));
printf("Finding account %d returns %d\n", MUHAMMET, find_account(accountNames,MUHAMMET,2));
return 1;
}
else
return -1;
}
//************************************************************************************//
//************************************LOGIN FUNCTION**********************************//
//***********************************************************************************//
int login(int accountNums[],char *accountNames[100],char *accountPins[],double accountBalance[],int numAccts);
{ int accountNum;
char *PIN;
printf("Please enter your account number.");
scanf("%d", &accountNum);
if(find_account(accountNums[],accountNum,numAccts)==1){
printf("Please enter your pin:");
gets(PIN);
if(strcmp(PIN,"0111")==0 || strcmp("9876",PIN)==0)
{
atm (accountNames[],accountBalance[]);
}
else
printf("Pin not correct.");
}
else printf("Account is not found");
}
//**********************************************************************************//
//*******************************MAIN FUNCTION*************************************//
//********************************************************************************//
int main()
{
int accountNums [2] = {12345,67890};
char *accountNames [100] = {"CS111", "MUHAMMET"};
char *accountPins [2] = { "01111", "98765"};
double accountBalance [2] = 10000.00,250.00;
login(accountNums,accountNames,accountPins,accountBalance,2);
}