#include #include using namespace std; class Account { protected: string name; string acc_no; double balance; public: Account(string name, string acc_no, double balance = 0) : name(name), acc_no(acc_no), balance(balance) {} virtual void deposit(double amount) { balance += amount; cout << "Deposit successful. Updated balance: " << balance << endl; } virtual void display_balance() { cout << "Account Balance: " << balance << endl; } virtual void withdrawal(double amount) { if (amount <= balance) { balance -= amount; cout << "Withdrawal successful. Updated balance: " << balance << endl; } else { cout << "Insufficient balance" << endl; } } }; class SavingsAccount : public Account { public: SavingsAccount(string name, string acc_no, double balance = 0) : Account(name, acc_no, balance) {} void compute_interest(double interest_rate) { double interest = balance * interest_rate; deposit(interest); cout << "Interest deposited. Updated balance: " << balance << endl; } }; class CurrentAccount : public SavingsAccount { private: double min_balance; double service_charge; public: CurrentAccount(string name, string acc_no, double balance = 0, double min_balance = 1000, double service_charge = 50) : SavingsAccount(name, acc_no, balance), min_balance(min_balance), service_charge(service_charge) {} void check_minimum_balance() { if (balance < min_balance) { balance -= service_charge; cout << "Minimum balance not maintained. Service charge imposed. Updated balance: " << balance << endl; } else { cout << "Minimum balance maintained." << endl; } } void withdrawal(double amount) override { Account::withdrawal(amount); check_minimum_balance(); } }; int main() { string name, acc_no; double balance, amount, interest_rate; int choice; cout << "Choose account type:\n"; cout << "1. Savings Account\n"; cout << "2. Current Account\n"; cout << "Enter your choice (1 or 2): "; cin >> choice; cin.ignore(); // Ignore newline character from the previous input cout << "Enter name: "; getline(cin, name); cout << "Enter account number: "; getline(cin, acc_no); cout << "Enter initial balance: "; cin >> balance; if (choice == 1) { SavingsAccount savings_account(name, acc_no, balance); cout << "Enter interest rate (in decimal): "; cin >> interest_rate; cout << "Enter amount to deposit: "; cin >> amount; savings_account.deposit(amount); savings_account.compute_interest(interest_rate); savings_account.display_balance(); cout << "Enter amount to withdraw: "; cin >> amount; savings_account.withdrawal(amount); savings_account.display_balance(); } else if (choice == 2) { CurrentAccount current_account(name, acc_no, balance); cout << "Enter amount to deposit: "; cin >> amount; current_account.deposit(amount); cout << "Enter amount to withdraw: "; cin >> amount; current_account.withdrawal(amount); current_account.display_balance(); } else { cout << "Invalid choice." << endl; } return 0; }