#include <iostream>
#include <stdlib.h>
#include <conio.h>
using namespace std;
struct ACC
{
int accID;
char pw[5];
char name[20];
int bal;
};
void menu(int &sel);
void mkacc(ACC &in);
void save(ACC &in);
void withdraw(ACC &in);
void balance(ACC &in);
int main()
{
ACC reval = {1111};
int choice;
while(1)
{
menu(choice);
switch(choice)
{
case 1:
mkacc(reval);
break;
case 2:
save(reval);
break;
case 3:
withdraw(reval);
break;
case 4:
balance(reval);
break;
case 5:
exit(1);
}
}
return 0;
}
void menu(int &sel)
{
system("cls");
cout << "\n[ 메 뉴 선 택 ]\n\n";
cout << "1. 계좌등록\n";
cout << "2. 입 금\n";
cout << "3. 출 금\n";
cout << "4. 잔액조회\n";
cout << "5. 종 료\n";
cout << "\n\n선택 : [ ]\b\b";
cin >> sel;
}
void mkacc(ACC &in)
{
system("cls");
cout << "\n\n\t\t[ 계 좌 등 록 ]\n\n";
cout << "계좌번호 : " << in.accID << endl;
cout << "이 름 : ";
cin >> in.name;
cout << "비밀번호(4자리) : ";
cin >> in.pw;
cout << "입 금 액 : ";
cin >> in.bal;
cout << "\n\n\n\t\t계좌 등록 완료!" << "\n\n\t\t아무키나 누르면 메뉴로 돌아갑니다.";
getch();
}
void save(ACC &in)
{
system("cls");
int inmoney;
cout << "\n\n\t[ 입\t금 ]\n\n";
cout << "입금액 : ";
cin >> inmoney;
cout << "\n\n\n\t\t[" << inmoney << "]원 입금완료!\n\n";
cout << "\t\t아무키나 누르면 메뉴로 돌아갑니다.";
in.bal += inmoney;
getch();
}
void withdraw(ACC &in)
{
system("cls");
int outmoney;
cout << "\n\n\t[ 출\t금 ]\n\n";
cout << "출금액 : ";
cin >> outmoney;
if(outmoney <= in.bal)
{
cout << "\n\n\n\t\t[" << outmoney << "]원 출금 완료!\n\n";
in.bal -= outmoney;
}
else
{
cout << "\n\n\n\t\t잔액이 부족합니다.\n\t\t";
cout << "[" << in.name << "]회원님의 잔액은 [" << in.bal << "]원 입니다.";
}
cout << "\n\n\t\t아무키나 누르면 메뉴로 돌아갑니다.";
getch();
}
void balance(ACC &in)
{
system("cls");
cout << "\n\n\t[ 잔 액 조 회 ]\n\n";
cout << "계좌번호 : " << in.accID << endl;
cout << "\n\n\n\t\t[" << in.name << "]회원님의 잔액은 [" << in.bal << "]원 입니다.\n\n";
cout << "\t\t아무키나 누르면 메뉴로 돌아갑니다.";
getch();
}