Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Here is the code before in C++: #include #include #include using namespace std; static time_t now = time(0); static tm *ltm = localtime(&now); class BankAccount

Here is the code before in C++:

#include #include #include

using namespace std;

static time_t now = time(0); static tm *ltm = localtime(&now);

class BankAccount {

protected: double balance, interestRate; struct tm lastInterestDate;

public:

BankAccount() {

balance = 0; interestRate = 0; lastInterestDate.tm_mon = 0; lastInterestDate.tm_year = 0; lastInterestDate.tm_mday = 1; lastInterestDate.tm_sec = 0; lastInterestDate.tm_min = 0; lastInterestDate.tm_hour = 0; }

BankAccount(double b, double r, struct tm lid = *ltm) {

balance = b; interestRate = r; lastInterestDate = lid; }

void withdraw(double deduction)

{ if (balance

void setBalance(double b) { balance = b; }

void increaseBalanceBy(double amount) { balance += amount; }

void setInterestRate(double r) { if (r 1) { cout

interestRate = r; }

void deposit(double addition) { balance += addition; } void addInterest() { time_t t = time(NULL); struct tm now; localtime_s(&now, &t); int today = (now.tm_year + 1990) * 10000 + (now.tm_mon + 1) * 100 + (now.tm_mday); cout 30) { balance = balance + balance * interestRate; lastInterestDate.tm_mday = today; } }

void info() { std::ios cout_state(NULL); cout_state.copyfmt(cout); cout

class walletAccount :public BankAccount

{ private: double maxWalletCapacity = 100;

public: walletAccount() :BankAccount() { } walletAccount(double bal, double rate) :BankAccount(bal, rate) { } double getMaxWalletCapacity() { return maxWalletCapacity; } void deposit(double addition) { if ((balance + addition)

class SavingAccount :public BankAccount

{ private: bool lock = false; void accountLockMessage() { if (lock) cout

public: SavingAccount(double bal, double rate, bool lock) :BankAccount(bal, rate) { this->lock = lock; } void lockAccount() { lock = true; accountLockMessage(); } void removeLock() { lock = false; accountLockMessage(); } void setBalance(double bal) { if (lock == false) balance = bal; else cout

int main() { SavingAccount saving(1000, 0.02, true); saving.printInfo(); saving.withdraw(200); saving.removeLock(); saving.withdraw(300); saving.withdraw(1000); saving.lockAccount(); saving.deposit(2000); saving.printInfo();

walletAccount wallet(70.0, 0.02); wallet.printInfo(); wallet.deposit(50); wallet.printInfo(); }

image text in transcribedimage text in transcribedimage text in transcribed

Write a new main function: o (3 point) Create a pointer for class SavingsAccount and initialize it o (3 point) Create a pointer for class WalletAccount and initialize it o (2 point) Print the current number of accounts Hint: use static method defined in BankAccount o (2 point) Ask user if he wants to open an account o (2 point) If no show a message o If yes (2 point) Ask if he wants to open a savings account If yes (1 point) ask for balance . (7 point) create a new SavingsAccount object assign it to savings pointer (2 point) Ask if he wants to open a wallet account - If yes (1 point) Ask for balance (7 point) Create a new WalletAccount object Assign it to wallet pointer o (3 point) Print the current number of accounts * (15 point) Possible output: . Run the code three time Try the same inputs provided in sample outputs . Get a screenshot of each results Save all vour files in a folder Make a zip and submit it through canvas urrent number of accounts is: e Do you want to open an account? (y)rn aybe some other time! urrent number of accounts is: e Press any key to continue . . urrent number of accounts is: you want to open an account? (y)y o you want to open a savings account with 2% int reast rate? (y)y hat is your initial balance? 180 you want to open a wallet account with 2% intreast rate and $100 maximim capacity? (y)n urrent number of accounts is: 1 ress any key to continue . . . _ urrent number of accounts is: e o you want to open an account? (y)y Do you want to open a savings account with 2% intre ast rate? (y)y hat is your initial balance? 1ee O you want to open a wallet account with 2% intreast rate and $10 maximim capacity? (y)y hat is your initial balance? 38 urrent number of accounts is: 2 Press any key to continue .. . _

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases DeMYSTiFieD

Authors: Andy Oppel

2nd Edition

0071747990, 978-0071747998

More Books

Students also viewed these Databases questions

Question

List and describe three contingency leadership theories.

Answered: 1 week ago