#include<stdio.h>
#include<conio.h>
main()
{
int num, dep, with, bal;
clrscr();
num=1;
printf("MENU");
printf("\n\n1. Deposit\n2. Withdraw\n3. Check Balance");
printf("\n\nEnter a number of choice: ");
scanf("%d", &num);
switch(num)
{
case 1: printf("\n\n\nEnter an amount to be deposited: ");
scanf("%d", &dep);
{
printf("You have successfully deposited an amount of %d.", dep);
}
getch();
case 2: printf("\n\nEnter an amount to be withdrawn: ");
scanf("%d", &with);
{
num=dep-with;
printf("\n\nYou have succesfully withrawn %d", with);
}
getch();
case 3: printf("\n\nYour current balance is %d.", num);
}
getch();
}
and
#include<stdio.h>
#include<conio.h>
main()
{
int choice;
float balance = 0.0;
do{
float amount = 0.0;
do{
clrscr();
printf("MENU\n1. Deposit\n2. Withdraw\n3. Balance Inquiry\n");
printf("4. Fast Cash\n5. Exit\nEnter choice: ");
scanf("%d",&choice);
if (choice < 1 || choice > 5)
{
printf("Error in choice.\nPress any key to continue.");
getch();
}
}while(choice < 1 || choice > 5);
switch(choice)
{
case 1: printf("Enter amount to deposit: ");
scanf("%f",&amount);
if (amount < 0.01)
{
printf("Error in input of amount. ");
printf("Press any key to continue.");
getch();
}
else
{
balance += amount;
printf("You deposited %.2f.\n");
printf("Your current balance is %.2f",amount,balance);
printf("\nPress any key to continue.");
getch();
}
break;
case 2: if (balance > 0.0)
{
printf("Enter amount to withdraw: ");
scanf("%f",&amount);
if(amount < 0.01 || amount > balance)
{
printf("Error in input of amount. ");
printf("Press any key to continue.");
getch();
}
else
{
balance -= amount;
printf("You withdrew %.2f.\n",amount);
printf("Your current balance is %.2f",balance);
printf("\nPress any key to continue.");
getch();
}
}
else
{
printf("Insufficient funds.\nPress any key to continue.");
getch();
}
break;
case 3: printf("Your balance is %.2f.\n",balance);
printf("Press any key to continue.");
getch();
break;
case 4: if(balance >= 100.0)
{
int c;
printf("FASTCASH MENU\n1. 100\n2. 200\n3. 500\n4. 1000\n");
printf("Enter choice: ");
scanf("%d",&c);
switch(c)
{
case 1: amount = 100.0;
break;
case 2: amount = 200.0;
break;
case 3: amount = 500.0;
break;
case 4: amount = 1000.0;
break;
default: printf("Choice does not exist. ");
printf("Press any key to continue.");
getch();
amount = 0.0;
}
if(balance >= amount)
{
balance -= amount;
printf("You withdrew %.2f.",amount);
printf("Your current balance is %.2f",balance);
printf("\nPress any key to continue.");
getch();
}
else
{
printf("Insufficient funds.\nPress any key to continue.");
getch();
}
}
else
{
printf("Insufficient funds.\nPress any key to continue.");
getch();
}
}
}while(choice != 5);
}
here are some atm program I just made... the problem is I don't know how function works... Need guidance guys! Gotta finish it ASAP... XD