#include <iostream>
using namespace std;

class Account {
protected:
    double balance;

public:
    Account(double b) {
        balance = b;
    }

    double getBalance() {
        return balance;
    }
};

class SavingsAccount : public Account {
private:
    double interestRate;

public:
    SavingsAccount(double b, double rate) : Account(b) {
        interestRate = rate;
    }

    double calculateFinalAmount() {
        return balance + (balance * interestRate);
    }
};

int main() {
    SavingsAccount sa(1000, 0.05);
    cout << "최종 금액: " << sa.calculateFinalAmount() << endl;
    return 0;
}

Embed on website

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