#include <iostream>
using namespace std;

class Account {
public:
    string name;
    int balance = 0;

    void deposit(int m) {
        balance += m;
    }

    void withdraw(int m) {
        if (m > balance) {
            cout << "잔액 부족" <<endl;
        } else {
            balance -= m;
        }
    }
};

int main() {
    Account acc;

        cin >> acc.name;


        int n;
        cin >> n;

        for (int i = 0; i < n; i++) {
            char type;
            int a;
            cin >> type >> a;
            if (type == 'd') {
                acc.deposit(a);
            } else if (type == 'w') {
                acc.withdraw(a);
            }
        }
    

        cout << "예금주 이름: " << acc.name << endl;
        cout << "잔액: " << acc.balance << "원" << endl;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: