银行窗口显示C++代码
时间: 2023-07-10 08:23:11 浏览: 41
以下是一个简单的银行窗口的 C++ 代码示例:
```cpp
#include <iostream>
#include <string>
using namespace std;
int main() {
string name;
double balance = 0;
int option = 0;
cout << "Welcome to the bank!" << endl;
while (true) {
cout << "1. Check balance" << endl;
cout << "2. Deposit money" << endl;
cout << "3. Withdraw money" << endl;
cout << "4. Exit" << endl;
cout << "Enter option (1-4): ";
cin >> option;
if (option == 1) {
cout << "Your balance is $" << balance << endl;
} else if (option == 2) {
double deposit;
cout << "Enter amount to deposit: $";
cin >> deposit;
balance += deposit;
cout << "New balance is $" << balance << endl;
} else if (option == 3) {
double withdraw;
cout << "Enter amount to withdraw: $";
cin >> withdraw;
if (withdraw > balance) {
cout << "Insufficient funds." << endl;
} else {
balance -= withdraw;
cout << "New balance is $" << balance << endl;
}
} else if (option == 4) {
cout << "Thank you for banking with us!" << endl;
break;
} else {
cout << "Invalid option. Please try again." << endl;
}
}
return 0;
}
```
注:这只是一个简单的示例,实际的银行窗口应用程序可能需要更多的功能和安全性措施。