ATM Machine using C language
PURPOSE : ATM MACHINE DATE : 15 JULY 2020*/
#include <stdio.h>void main(void){ int i, choice; float cash = 0; char c;
do { printf("Enter the Number to perform the transaction\n"); printf("1. Withdrawal\n"); printf("2. Deposit\n"); printf("3. Check Balance\n"); scanf("%d", &choice); switch (choice) { case 1: { int withdraw; printf("Enter Amount to withdraw\n"); scanf("%d", &withdraw); if (withdraw % 100 == 0) { if (cash >= withdraw) { cash -= withdraw; printf("Amount After withdrawal of cash is %.2f\n", cash); } else { printf("You don't have enough Amount to Withdraw.Please Deposit Amount\n"); } } else { printf("Enter Withdrawal Amount in 100's\n"); } break; } case 2: { int deposit; printf("Enter Amount to deposit\n"); scanf("%d", &deposit); if (deposit % 100 == 0) { cash = cash + deposit; printf("Balance After Depositing Amount is %.2f\n", cash); } else { printf("Please Enter Amount in 100's\n"); } break; } case 3: { printf("Balance in the Account is %.2f\n", cash); break; } default: { printf("Enter Valid Choice\n"); break; } } printf("To Continue Press 'Y' else any letter\n"); fflush(stdin); scanf("%c", &c); } while (c == 'y' || c == 'Y'); printf("Thanks for using our ATM\n");}
PURPOSE : ATM MACHINE
DATE : 15 JULY 2020*/
#include <stdio.h>
void main(void)
{
int i, choice;
float cash = 0;
char c;
do
{
printf("Enter the Number to perform the transaction\n");
printf("1. Withdrawal\n");
printf("2. Deposit\n");
printf("3. Check Balance\n");
scanf("%d", &choice);
switch (choice)
{
case 1:
{
int withdraw;
printf("Enter Amount to withdraw\n");
scanf("%d", &withdraw);
if (withdraw % 100 == 0)
{
if (cash >= withdraw)
{
cash -= withdraw;
printf("Amount After withdrawal of cash is %.2f\n", cash);
}
else
{
printf("You don't have enough Amount to Withdraw.Please Deposit Amount\n");
}
}
else
{
printf("Enter Withdrawal Amount in 100's\n");
}
break;
}
case 2:
{
int deposit;
printf("Enter Amount to deposit\n");
scanf("%d", &deposit);
if (deposit % 100 == 0)
{
cash = cash + deposit;
printf("Balance After Depositing Amount is %.2f\n", cash);
}
else
{
printf("Please Enter Amount in 100's\n");
}
break;
}
case 3:
{
printf("Balance in the Account is %.2f\n", cash);
break;
}
default:
{
printf("Enter Valid Choice\n");
break;
}
}
printf("To Continue Press 'Y' else any letter\n");
fflush(stdin);
scanf("%c", &c);
} while (c == 'y' || c == 'Y');
printf("Thanks for using our ATM\n");
}
No comments: