DevJourney · code I wrote while learning
main.cpp
455 B#include <iomanip>
#include <iostream>
using namespace std;
class BankAccount {
static float rate;
public:
static void setInterestRate(float r) { rate = r; }
static void calculateInterest(float balance) {
cout << fixed << setprecision(2) << balance * rate << endl;
}
};
float BankAccount::rate = 0.03;
int main() {
float r, b;
cin >> r >> b;
BankAccount::setInterestRate(r);
BankAccount::calculateInterest(b);
}