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

In C++ 1. Create a class named SavingsAccount 2. The class should be defined in

ID: 3837859 • Letter: I

Question

In C++

1. Create a class named SavingsAccount

2. The class should be defined in its own header file and have at least the following data members and functions:

Data Members

- accountOfficer, to represent the account officer who is responsible for the account.

- oDate, to represent the date that the account was opened.

- annualInterestRate, data member to represent the interest currently on the account. This value should be the same for all objects created.

- customer, to represent the Customer of this account.

- accountNumber, data member to represent the account number of the account.

- balance, data member to represent the current balance of the account.

Data members shared by all objects of the class:

- activeOfficer, to represent the current account officer who is creating accounts

- cdate, to represent today's date

Member functions:

- Default Constructor(), this constructor should initialize that data members appropriately

- Constructor(), this constructor should initialize that data members customer, savingsBalance, and accountNumber to the corresponding values passed to it.

- modifyInterestRate(), this function should modify the value of the data member annualInterestRate to the value of the parameter passed to it.

- updateSavingsBalance(), this function should calculate the monthly interest and update the savings balance data member with the interest results

- Any other methods as necessary

3. Write a class source code implementation file that contains any necessary declaration of the static variable in global space and code implemenation of all methods in the class.

4. Write a driver program to test this class. The program should:

- Prompt you to enter the current Account Officer on duty.

- Prompt you to enter today's date

- Prompt you to enter current interest rate.

- Create an array of pointers for up to some maximum number of accounts that can be created.

- Allow for the program to continuosly create new accounts (up to maximum) requesting the appropriate information each time.

5. Once all the accounts have been created, the program should:

- invoke a local function accumulateInterest() whose purpose is to update savings balance for each account created for one year (e.g. 12 months) of savings. This function should take as an argument the array of accounts and accumulate the interest for one year (i.e. 12 times) on each object of the array.

- invoke a local function to output a balance summary for each account.

Sample Run:

Current Account Officer: John Williams

Current Date: 11/14/2018

Current annual interest rate: 5%

Enter Customer name: Ted Johnson

Enter Starting balance: 10000.0

Enter Customer name: Raul Lopez

Enter Starting balance: 100.0

Enter Customer Name: -

Accumulating Interest for one year...

Account Officer Date Opened Customer Current Balance

John Williams 11/14/2018 Ted Jones $105000.00

John Williams 11/14/2018 Raul Lopez $105.0

Explanation / Answer

#include<iostream>
using namespace std;

class Name
{
private:

string firstname;
string lastname;
string middle_initial;

public:
Name();
Name(string, string, string);
void set_first_name(string);
void set_middle_name(string);
void set_last_name(string);
string get_first_name();
string get_middle_name();
string get_last_name();
void display();
};

Name::Name()
{
firstname="";
middle_initial="";
lastname="";
}
Name::Name(string f, string m, string l){
   firstname=f;
   middle_initial=m;
   lastname=l;
}
void Name::set_first_name(string fname)
{
firstname=fname;
}
void Name::set_middle_name(string mname)
{
middle_initial=mname;
}
void Name::set_last_name(string lname)
{
lastname=lname;
}
string Name::get_first_name()
{
return firstname;
}
string Name::get_middle_name()
{
return middle_initial;
}
string Name::get_last_name()
{
return lastname;
}
void Name::display()
{
cout<<""<<firstname;
cout<<" "<<middle_initial;
cout<<" "<<lastname;
}

class Date
{
private:
int month;
int day;
int year;
public:
Date();//Default constructor
Date(int, int, int);//overload constructor
int get_day();
int get_month();
int get_year();
void set_day(int);
void set_month(int);
void set_year(int);
void display();
};

Date::Date()
{
month=12;
year=2000;
day=10;
}
Date ::Date(int d, int m, int y)
{
day=d;
month=m;
year=y;
}
void Date::set_day(int d)
{
if(d>31||d<1)
cout<<"Invalid Day"<<endl;
else
day=d;
}
void Date::set_month(int m)
{
if(m<1 ||m>12)
cout<<"Invalid month"<<endl;
else
month=m;
}
void Date::set_year(int y)
{
year=y;
}
int Date::get_day()
{
return day;
}
int Date::get_month()
{
return month;
}
int Date::get_year()
{
return year;
}
void Date::display()
{
cout<<" " <<day<<"/"<<month<<"/"<<year;
}

class SavingsAccount{
   private:
   Name *customer;
   int accountNumber;
   double balance;
   public:
   static Name *accountOfficer;
   static Date *oDate;
   static double annualInterestRate;
   SavingsAccount(Name *cust,int account,double bal){
       customer=cust;
       accountNumber=account;
       balance=bal;
   }
   SavingsAccount(){
       customer=NULL;
       accountNumber=0;
       balance=0.0;
   }

   void displayName(){
       customer->display();
   }

   double getBalance(){
       return balance;
   }
};

Name *SavingsAccount::accountOfficer = NULL;
Date *SavingsAccount::oDate = NULL;
double SavingsAccount::annualInterestRate=0.0;

int main(){
   string fname = "John";
   string lname = "Williams";
   Name * name = new Name(fname,"",lname);
   Date * date = new Date(11,14,2018);
   double interest = 5.0;
   //SavingsAccount* acc;
   SavingsAccount::accountOfficer = name;
   SavingsAccount::oDate = date;
   SavingsAccount::annualInterestRate = 5.0;

   cout <<" Current Account Officer: ";
   SavingsAccount::accountOfficer->display();
   cout <<" Current Date:";
   SavingsAccount::oDate->display();
  
   cout << " Enter Customer Name(FirstName LastName) : ";
   string f,l;
   cin >>f>>l;
   cout << " Enter Starting balance : ";
   double bal;
   cin >>bal;
   Name * n = new Name(f,"",l);
   SavingsAccount ac(n,111,bal);

   cout << " Enter Customer Name(FirstName LastName) : ";
   cin >>f>>l;
   cout << " Enter Starting balance : ";
   cin >>bal;
   n = new Name(f,"",l);
   SavingsAccount ac1(n,191,bal);
  

   cout <<"Accumulating Interest for one year..."<<endl;
   ac.accountOfficer->display();
   cout<<" ";
   ac.oDate->display();
   cout<<" ";
   ac.displayName();
   cout<<" ";
   cout<<(ac.getBalance()+(ac.getBalance()/100.0*SavingsAccount::annualInterestRate))<<endl;

   ac1.accountOfficer->display();
   cout<<" ";
   ac1.oDate->display();
   cout<<" ";
   ac1.displayName();
   cout<<" ";
   cout<<(ac1.getBalance()+(ac1.getBalance()/100.0*SavingsAccount::annualInterestRate))<<endl;

   return 0;
}