Menu

[Solved]T Mobile Wi Fi 12 19 Pm Cheggcom Following Main Code Function Display Results Int Main0 Cr Q37138091

T-Mobile Wi-Fi 12:19 PM a chegg.com The following main code) should function and display the results below: int main0 //Creat.11 T-Mobile Wi-Fi 令 12:19 PM a chegg.com deposit) simply takes money as the amount variable, and adds it into the balance .T-Mobile Wi-Fi 12:19 PM a chegg.com The following main code) should function and display the results below: int main0 //Create an array of bank account pointers: BankAccount accounts[2] accounts[O]new CheckingAccount(5); accounts[0]->setOwner(“Betty”); accounts[o]->deposit (1000); accounts[O->withdraw(800); accounts[o]->withdraw(300); accounts[1]new SavingsAccount(0.0125); accounts[1]->setowner(“Joe and Betty”); accounts 1]->deposit(5000); accounts 1]->withdraw(3000); accounts[1]->withdraw(3000); I/This shouldn’t be allowed I/ This pointer needs to be cast to SavingsAccount because despositlnterest0 ll does not exist in the BankAccount. static_ cast<SavingsAccount*>(accounts[1])- >depositlnterest0; “<<accounts[o]->getBalance) << endl; “<<accounts[1]->getBalance)<<endl; cout << “Account 1:”<accounts[o]->getOwner0<<” cout <<“Account 2:”<<accounts[1]->getOwner0<<” delete accounts[O]; delete accounts[1 system( pause”); return 0 In order to make this work, you need a base class called BankAccount, and two derived classes called CheckingAccount and SavingsAccount. For BankAccount: . the getOwner) and setowner) methods are straightforward. They should set an owner and get an owner respectively . deposit() simply takes money as the amount variable .11 T-Mobile Wi-Fi 令 12:19 PM a chegg.com deposit) simply takes money as the amount variable, and adds it into the balance . . withdraw0 should check to make sure the requested amount is available in the balance. If so, decrement the balance. Otherwise, state “Cannot withdraw more than you have . getBalance) returns the existing balance For class CheckingAccount . It should inherit the BankAccount class . It needs a private double data member called feeForOverdraftWithdraw. Each time a withdrawal is made that puts the account into overdraft or deeper into overdraft, this fee should be also deducted from the balance . A constructor which has one parameter to set the feeForOverdraftWithdraw . It should override the withdraw0 method. It should always decrement the balance by the requested amount. In addition, if the balance is below O, it should also decrement the balance by the feeForOverdraftWithdraw amount. In order for this to work correctly with polymorphism, change the base class’s withdraw method to be virtual For class SavingsAccoun It should inherit the BankAccount class. . It needs a private double data member called monthlylnterestRate A constructor which has one parameter to set the monthlylnterestRate. Assume that an interest rate of 1.25% would be input as 0.0125. . It should have a void depositinterest0 method. This method should increase the balance by the monthlyInterestRate amount. If the classes are constructed correctly, you should get the correct output shown above. You may do this in a single file project if you desire, if you use multiple files, with each class using separate header (.h) and source (cpp) files and the main function placed in it’s own source file. Show transcribed image text T-Mobile Wi-Fi 12:19 PM a chegg.com The following main code) should function and display the results below: int main0 //Create an array of bank account pointers: BankAccount accounts[2] accounts[O]new CheckingAccount(5); accounts[0]->setOwner(“Betty”); accounts[o]->deposit (1000); accounts[O->withdraw(800); accounts[o]->withdraw(300); accounts[1]new SavingsAccount(0.0125); accounts[1]->setowner(“Joe and Betty”); accounts 1]->deposit(5000); accounts 1]->withdraw(3000); accounts[1]->withdraw(3000); I/This shouldn’t be allowed I/ This pointer needs to be cast to SavingsAccount because despositlnterest0 ll does not exist in the BankAccount. static_ cast(accounts[1])- >depositlnterest0; ”

Expert Answer


Answer to T-Mobile Wi-Fi 12:19 PM a chegg.com The following main code) should function and display the results below: int main0 //… . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *