BankAccount Withdraw Exception
BankAccount Withdraw Exception
Create a class BankAccount with a private double balance.
Requirements:
1. Constructor BankAccount(double initialBalance): throws std::invalid_argument with "Initial balance cannot be negative" if initialBalance < 0. Otherwise sets balance.
2. void deposit(double amount): throws std::invalid_argument with "Deposit amount must be positive" if amount <= 0. Otherwise adds to balance.
3. void withdraw(double amount): throws std::invalid_argument with "Withdraw amount must be positive" if amount <= 0; throws std::runtime_error with "Insufficient funds" if amount > balance. Otherwise subtracts from balance.
4. double getBalance() const: returns the current balance.
Do NOT write a main function.
Expected Output:
150= newline. The output ends with a newline — print one after the last line.
Your Output
Run your code to see the output here...