#include<iostream>
using namespace std;
class Date
{
private:
int year, month, day;
public:
void SetDate()
{
cout << "请输入开户年月日: ";
cin >> year >> month >> day;
}
void print()
{
cout << "开户时间:" << endl;
cout << "年: ";
cout << year << '\t';
cout << "月: ";
cout << month << '\t';
cout << "日: ";
cout << day << endl;
}
};
class BankAccount
{
private:
long long accNo;
double balance;
double money, takemoney;
public:
Date openDate;
void open()
{
cout << "输入账号名:" << endl;
cin >> accNo;
balance = 0;
}
void deposit()//实现存款功能
{
cout << "输入存款数额: ";
cin >> money;
cout << endl;
balance += money;
cout << "存款成功" << endl;
}
void withdraw()//实现取款功能
{
cout << "输入取款数额:";
cin >> takemoney;
cout << endl;
if (takemoney <= balance)
{
balance -= takemoney;
cout << "取款成功" << endl;
}
else
{
cout << "取款失败" << endl;
}
}
void print()
{
cout << "账号: ";
cout << accNo << endl;
cout << "账户金额: ";
cout << balance << endl;
}
};
int main()
{
BankAccount people;
while (true)
{
people.open();
people.openDate.SetDate();
people.deposit();
people.withdraw();
people.openDate.print();
people.print();
system("pause");
}
return 0;
}
简单银行信息系统
最新推荐文章于 2024-03-18 15:48:19 发布