1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 | #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() { } | cs |