#include <iostream>
using namespace std;
class Account {
private:
double balance;
public:
Account(double init_balance) {
balance = init_balance;
}
void deposit(double amount) {
balance += amount;
cout << amount << "원이 입금되었습니다. 현재 잔액: " << balance << "원" << endl;
}
void withdraw(double amount) {
if (amount > balance) {
cout << "잔액 부족" << endl;
} else {
balance -= amount;
cout << amount << "원이 출금되었습니다. 현재 잔액: " << balance << "원" << endl;
}
}
double getBalance() {
return balance;
}
};
int main() {
double init;
cin >> init;
Account myAccount(init);
myAccount.deposit(50000);
myAccount.withdraw(30000);
myAccount.withdraw(100000);
cout << "최종 잔액: " << myAccount.getBalance() << "원" << endl;
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: