#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
void mainMenu();
void checkBalance(int balance);
int moneyDeposit(int balance);
int moneyWithdraw(int balance);
void menuExit();
void errorMessage();
int main() {
int option = 0;
int balance = 10000;
int choose = 0;
bool again = true;
while (again) {
mainMenu();
scanf("%d", &option);
switch (option) {
case 1:
checkBalance(balance);
break;
case 2:
balance = moneyDeposit(balance);
break;
case 3:
balance = moneyWithdraw(balance);
break;
case 4:
menuExit();
return 0;
default:
errorMessage();
break;
}
system("CLS");
if (choose == 2) {
again = false;
menuExit();
}
}
return 0;
}
void mainMenu() {
printf("**********Welcome to ÄܼƮ ATM***********\n");
printf("****Çϳª¸¦ ¼±ÅÃÇϽÿÀ****\n");
printf("<1> ÀÜ°í È®ÀÎ\n");
printf("<2> ÀÔ±Ý\n");
printf("<3> ÀÎÃâ\n");
printf("<4> Á¾·á\n");
}
void checkBalance(int balance) {
printf("****ÀÜ°í´Â %dÀÔ´Ï´Ù.\n\n", balance);
printf("¾Æ¹«Å°³ª ´©¸£¼¼¿ä\n");
getch();
}
int moneyDeposit(int balance) {
int deposit;
printf("****ÀÔ±Ý ±Ý¾×À» ÀÔ·ÂÇϽÿÀ\n");
scanf("%d", &deposit);
balance += deposit;
printf("\n»õ·Î¿î ÀÜ°í´Â %dÀÔ´Ï´Ù.\n\n", balance);
printf("¾Æ¹«Å°³ª ´©¸£¼¼¿ä\n");
getch();
return balance;
}
int moneyWithdraw(int balance) {
int withdraw;
bool back = true;
while (back) {
printf("Ãâ±Ý ±Ý¾×À» ÀÔ·ÂÇϽÿÀ: \n");
scanf("%d", &withdraw);
if (withdraw < balance) {
back = false;
balance -= withdraw;
printf("\n»õ·Î¿î ÀÜ°í´Â %dÀÔ´Ï´Ù.\n\n", balance);
}
else {
}
}
getch();
printf("¾Æ¹«Å°³ª ´©¸£¼¼¿ä\n");
return balance;
}
void menuExit() {
}
void errorMessage() {
}