atm.c 1.42 KB
#include <stdio.h>
#include<stdlib.h>
#define PIN 1010
int amount = 1000, deposit, withdraw;
int choice, pin, k = 0;
int main(){
while (pin != PIN)
{
printf("Enter Pin: ");
scanf("%d", &pin);
getchar();
if (pin != PIN)
printf("Invalid Pin! ");
}
printf("***** Welcome to ECE15's ATM *****\n");
do
{
printf("***** Select Service *****\n");
printf("1. Check Balance\n");
printf("2. Withdraw Cash\n");
printf("3. Deposit Cash\n");
printf("4. Quit\n");
printf("***** ***** *****\n");
printf("Your Choice: ");
scanf("%d", &choice);
getchar();
switch (choice) {
case 1:
printf("Your Balance is: $%d\n", amount);
break;
case 2:
printf("Withdrawal Amount in $: ");
scanf("%d", &withdraw);
if (withdraw % 5 != 0) {
printf("Not a multiple of 5!\n");
}
else if (withdraw >(amount - 100))
{
printf("Insufficient Balance!\n");
}
else
{
amount = amount - withdraw;
printf("Please collect your cash!\n");
printf("Your new balance is: $%d\n", amount);
}
break;
case 3:
printf("Deposit Amount in $: ");
scanf("%d", &deposit);
amount = amount + deposit;
printf("Your new balance is: $%d\n", amount);
break;
case 4:
break;
default:
printf("Invalid choice!\n");
}
} while (choice != 4);
printf("Thanks for using the ECE15's ATM!\n");
return 0;
}