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

Hi I need help writing this code , I have completed the first part . I need head

ID: 3883568 • Letter: H

Question



Hi I need help writing this code , I have completed the first part . I need header file and source codes for the other two classes. Along with the code that I need to add to the main. Thanks so much for the help Window Help 60% s Assignment1.pdf (page 1 of 2) Q Search The Account Inheritance Hierarchy has 3 classes. The base class is Account: · One data member called balance of data type double. A constructor that takes one parameter to initialize the data member balance. The constructor should validate the initial balance to make sure it is more than 0. If the initial balance is less than zero, then set the balance to zero and display an error message. o o o A member function called credit to allow the user to add value to the balance. The function should take one parameter and return the new balance. o A member function called debit to allow the user to withdraw money from the account. The function should check if there is sufficient fund for the withdrawal. The function should take one parameter (the amount of withdrawal) and return true/false (Boolean data type) to indicate the success or failure of the transaction, respectively. Display an error message if there isn't sufficient fund for the withdrawal. o A member function getBalance to return the account's current balance. o A member function setBalance to re-initialize the account's balance. The class SavingAccount is a class derived from the class Account The SavingAccount inherits all data members and functions from the base class o An additional data member of type double indicating the interest rate (percentage o A constructor that receives the initial balance, as well as an initial value for the Account. assigned to the account. SavingsAccount's interest rate. 5 6

Explanation / Answer

#include<iostream.h>
class Account
{
   protected:
   double balance;
   public:
   Account(double bal)
   {  
       if(bal>=0.0)
       {  
           balance=bal;
       }
       else
       {
           balance=0;
           cout<<" invalid initial balance ";
       }
   }
   void credit()
   {
       cout<<"Enter the amount to credit ";
       int a;
       cin>>a;
       balance=balance+a;

   }
   void debit()
   {
       cout<<"Enter the amount to withdraw ";
       int g;
       cin>>g;
       if(g>=balance)
       {
           balance=balance-g;
       }
       else
           cout<<"No enough balance ";

   }
   void getBalance()
   {
       cout<<"Your current balance is:"<<balance<<endl;
   }

};

class SavingsAccount:public Account
{
   private:
   double interestrate;
   public:
   SavingsAccount(double bal, double interest):Account()
   {
       balance=bal;
       interestrate=interest;
   }
   double calculateInterest()
   {
       double interestearned=interestrate*balance;
       return interestearned;

   }
   void setInterest(double interest)
   {
       interestrate = interest;
      

   }
   double getInterest()
   {
      
       return interestrate;

   }
};
class CheckingAccount:public Account
{
   private:
   double fee;
   public:
   CheckingAccount(double bal, double f):Account()
   {
       balance = bal;
       fee=f;
   }
  
   void chargeFee()
   {
       balance= balance-fee;
   }
   void setFee(double f)
   {
       fee = f;
      

   }
   double getFee()
   {
      
       return fee;

   }
  


};
void main()
{
  
   Account a(1000);
  
   SavingsAccount s(1000, 1.5);
   cout<<"Enter fee ";
   double fee;
   cin>>fee;
   CheckingAccount c(1000,fee);
}