Description 1) This project will use an account class that has the members: std
ID: 3777958 • Letter: D
Question
Description 1) This project will use an account class that has the members: std stri ng account code: std: string first name. std string last name: double balance; Provide a constructor that initializes ALL members in its initialization list with data passed in as arguments to the constructor. You will also need accessor functions to get the account code and balance and to set the balance. In addition, include two pure virtual functions that look like the following: virtual void monthly update0 0: virtual char type0 const 0; 2) Design and implement the following derived classes that will inherit from account and implement the monthly update function in the following manner: Implementation Class Name simple account balance 1.05 balance balance (balance 5000 106 104) bonus account service account balance (balance 5.0) 1.04 balanced account balance balance 500.0 balance 105 balance 500 103 The type function returns a single character that describes the type as indicated in the part 3. Use thi virtual function to indicate the account type instead of storing the character. create a factory function or class that reads data in the following fixed format: account code 10 characters first name: 15 characters last name: 25 characters type: 1 character balance numeric 8 digits, decimal place, 2 digits and uses that data to allocate and construct one of the derived objects based on the value type as indicated in the following table:Explanation / Answer
// Solution for 1 and 2 is
#include <iostream>
using namespace std;
class account{
public:
string account_code;
string first_name;
string last_name;
double balance;
account(string code, string fname, string lname, double bal)
{
account_code = code;
first_name = fname;
last_name = lname;
balance = bal;
}
void enterData()
{
cout<<"Enter Account code";
cin>>account_code;
cout<<"Enter balance";
cin>>balance;
}
virtual void monthly_update() = 0;
virtual char type() = 0;
};
class simple_account: account{
void monthly_update()
{
balance = balance*1.5;
}
char type()
{
return'A';
}
};
class bonus_account: account{
void monthly_update()
{
balance = balance*(balance>5000?1.06:2.04);
}
char type()
{
return'B';
}
};
class service_account: account{
void monthly_update()
{
balance = (balance-5.0)*1.4;
}
char type()
{
return'C';
}
};
class balanced_account: account{
void monthly_update()
{
balance = balance>500.0?(balance*1.05):(balance-5.0)*1.03;
}
char type()
{
return'D';
}
};
int main()
{
return 0;
}