Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

From Week 7 Assignment, we created the Account class with a static annual intere

ID: 3759886 • Letter: F

Question

From Week 7 Assignment, we created the Account class with a static annual interest rate variable, a member function calculateMonthlyInterest, and a static member function modifyInterestRate that sets the static annualInterestRate to a new value. In this assignment, you will create one derived class, CDAccount, public inheritanted from the base class, Account. You will add two private variables, duration (in months) and CDannualInterestRate, and four member functions, getDuration(), setDuration(), getCDannualInterestRate(), and setCDannualInterestRate(). Every three months CD duration will increase the CDannualInterestRate by 0.5% from annualInterestRate of the base class. For example: if annualInterestRate is 3%, the CDannualInterestRate will be 3.5% of a three-months CD saving account, and the CDannualInterestRate will be 4% of a six-month CD. Make the necessary changes in both base class and derived class. The public function calculateMonthlyInterest() in the derived class will not only calculate the monthly interest of every month in the duration, but also print out the monthly interest. Write a driver program to test class CDAccount. Instantiate five different objects of class CDAccount, CDsaver1 to CDsaver5, with balances of $1000.00 to $5000.00, and duration from 3-month to 15-months respectively. Set the annualInterestRate to 3%. Calculate and print the monthly interest of every month during the saving period for each CDAccount. Display both CDannualInterestRate and the mature date.

week 7's code

1. header

#ifndef ACCOUNT

#define ACCOUNT

#include<iostream>

#include<string>

using namespace std;

/* class */

class Account

{

   /* variable declarations and methods used */

public:

   // Constructor for Account with default values specified to be 0 for both id and balance
   Account(int custID = 0, double balance = 0);

   // getter for account Id
   int getId();

   // setter for account Id
   void setId(int custID);

   // getter for account Balance
   double getBalance();

   // setter for account Balance
   void setBalance(double balance);

   // getter for annual Interest Rate
   static double getAnnualInterestRate();

   // setter for annual Interest Rate
   static void setAnnualInterestRate(double interestRate);

   // returns monthly interest rate i.e. annualInterestRate / 12
   double getMonthlyInterestRate();

   // returns monthly Interest i.e. balance * monthlyInterestRate / 100
   double getMonthlyInterest();

   // withdraws "withdrawAmount" amount from balance and decrements the balance by the same
   void withdraw(double withdrawAmount);

   // deposits "depositAmount" amount to balance and increments the balance by the same
   void deposit(double depositAmount);

private:

   int id;

   double balance;

   static double annualInterestRate;

};

#endif#pragma once

2. source

/* Account.cpp */

#include "Account.h"

#include <iostream>

#include <string>

using namespace std;

/* constructor */

Account::Account(int custID, double balance)
{
   id = custID;
   this->balance = balance;

}

int Account::getId()
{
   return id;
}

void Account::setId(int custID)
{
   id = custID;
}

double Account::getBalance()
{
   return balance;
}

void Account::setBalance(double balance) {
   this->balance = balance;
}

double Account::getAnnualInterestRate()
{
   return annualInterestRate;
}

void Account::setAnnualInterestRate(double interestRate)
{
   annualInterestRate = interestRate;
}

double Account::getMonthlyInterestRate()
{
   return annualInterestRate / 12;
}

double Account::getMonthlyInterest()
{
   return balance * (getMonthlyInterestRate() / 100);
}

void Account::withdraw(double withdrawAmount)
{
   if (balance >= withdrawAmount) {
       balance -= withdrawAmount;
   }
   else {
       cout << "Insufficient balance...";
   }

}

void Account::deposit(double depositAmount)
{
   balance += depositAmount;
}

double Account::annualInterestRate;

3. main

/* main.cpp */

#include <cstdlib>

#include <iostream>

#include <iomanip>

#include "Account.h"

using namespace std;

void print(Account holder);

int main(int argc, char *argv[])

{
   Account::setAnnualInterestRate(3.00);

   Account person1(1000.00, 1000);
   person1.withdraw(500.00);
   person1.deposit(1000.00);

   Account person2(2000.00, 2000);
   person2.withdraw(500.00);
   person2.deposit(1000.00);

   Account person3(3000.00, 3000);
   person3.withdraw(500.00);
   person3.deposit(1000.00);

   Account person4(4000.00, 4000);
   person4.withdraw(500.00);
   person4.deposit(1000.00);

   Account person5(5000.00, 5000);
   person5.withdraw(500.00);
   person5.deposit(1000.00);

   // setting the width of all columns in the output to 20 characters
   cout << setw(20) << std::right;
   cout << "Account Number";

   cout << setw(20) << std::right;
   cout << "Monthly Interest";

   cout << setw(20) << std::right;
   cout << "Balance";

   cout << endl;

   /*
   Printing a separator line by repeating the "=" character 62 times.
   62 times because there are 3 columns(Account Number, Monthly Interest and
   Balance) each of width 20 and keeping a margin of 1 character on both ends.
   Hence, width of separator = 1 + 20 + 20 + 20 + 1
   */
   cout << std::string(62, '=') << endl;

   print(person1);
   print(person2);
   print(person3);
   print(person4);
   print(person5);

   return 0;

}

void print(Account holder)
{
   // setting the width of each column in the output to 20 characters
   cout << setw(20) << std::right;
   cout << holder.getId();

   double monthlyInterest = holder.getMonthlyInterest();
   cout << setw(20) << std::right;
   //setting precision of monthlyInterest to display decimal points
   cout << std::setprecision(7) << monthlyInterest;
   holder.deposit(monthlyInterest);

   cout << setw(20) << std::right;
   //setting precision of monthlyInterest to display decimal points
   cout << std::setprecision(7) << holder.getBalance();

   cout << endl;
}

Iccount ID Annual Interest Rate (R Duration months) Initial Balance 1000 3.58 1998.90 inth 1 1992.92 Month 2 1905.84 nth 3 1998.28 Iccount ID Annual Interest Rate C> Duration Conths > Initial Balance 2009 4. BA 2008.90 nth 1 2a86.62 onth 2 2013.36 Month 3 2020.87 Month 4 2026.80 Month 5 2033.56 nth 6 2048.33 Iccount ID Annual Interest Rate (2) Duration monthsInitial Balance 3999 4.5 3999.99 lionth 1 3911.25 Month 2 3022.54 Month 3 3033.88 Month 4 3045.25 Month 5 3056.67 Month 6 368.14 month 7 3979.64 Month 8 3091-19 nth 9 312.78 , account ID Annual Interest Rate (2) Duration monthsInitial Balance 49.9 5.99 4999.99 inth 1 4916.67 Month 2 133.19 Month 3 1950.21 Month 4 4067.08 Month 5 4084.03 month 6 4191.95 Month ? 4118.14 Month 8 4135.29 month 9 4152.52

Explanation / Answer

nclude #include class account { char cust_name[20]; int acc_no; char acc_type[20]; public: void get_accinfo() { coutcust_name; coutacc_no; coutacc_type; } void display_accinfo() { cout
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote