I provided the code for the first part, please write the answer in one single code. #include using namespace s
Posted: Fri Apr 29, 2022 7:12 am
I provided the code for the first part, please write the
answer in one single code.
#include<iostream>
using namespace std;
class Client_information
{
private:
string firstname;//private hide the details from
main class
string lastname;
public:
//default constructor
Client_information() {}
//parameterized constructor
Client_information(string n, string a)
{
firstname = n;
lastname = a;
}
//getter function
string getFName()
{
return firstname;
}
string getlname()
{
return lastname;
}
//setter function
void SetfName(string n)
{
firstname = n;
}
void SetAdd(string n)
{
lastname = n;
}
//output
void print()
{
cout << "\nFirst
Name\t:\t" << firstname;
cout << "\nLast
Name\t:\t" << lastname;
}
};
//date data type using class
class DateType
{
private:
int dd;
int mm;
int yy;
public:
DateType()
{
dd = 1;
mm = 1;
yy = 2000;
}
DateType(int d, int m, int y)
{
dd = d;
mm = m;
yy = y;
}
void setDate(int d, int m, int y)
{
dd = d;
mm = m;
yy = y;
}
void setDay(int d)
{
dd = d;
}
void setMonth(int m)
{
mm = m;
}
void setYear(int y)
{
yy = y;
}
int getDay()
{
return dd;
}
int getMonth()
{
return mm;
}
int getYear()
{
return yy;
}
void inputDate()
{
cout << "\nEnter
Year\t:\t";
cin >> yy;
cout << "\nEnter
Month\t:\t";
cin >> mm;
while (mm < 1 ||
mm>12)// checking month from 1-12
{
cout
<< "\n Invalid Month";
cout
<< "\nEnter Month(1-12)\t:\t";
cin
>> mm;
}
cout << "\nEnter
Day\t:\t";
cin >> dd;
if (mm == 1 == 3 == 5 == 7 ==
8 == 10 == 12)// checking month for 31 days
{
while (dd
< 1 || dd>31)
{
cout << "\n Invalid Day";
cout << "\nEnter
Month(1-31)\t:\t";
cin >> dd;
}
}
else
if (mm ==
4 == 6 == 9 || mm == 11)// checking month for 30 days
{
while (dd < 1 || dd>30)
{
cout << "\n
Invalid Day";
cout << "\nEnter
Month(1-30)\t:\t";
cin >> dd;
}
}
else
{
while (dd < 1 || dd>28)
{
cout <<
"\nInvalid Day";
cout << "\nEnter
Month(1-28)\t:\t";
cin >> dd;
}
}
}
//Print date according to given format
void printDate()
{
cout << mm << "/"
<< dd << "/" << yy;
}
};
class Account
{
protected:
int accntNo;//protected is example of data
abstraction
//using object of another class
double Balance;
//default Constructor
public:
Account()
{
accntNo = 0;
Balance = 0;
}
//parametrized constructor overloading
concept(polymorphism)
Account(int c, double b)
{
accntNo = c;
Balance = b;
}
//setter function
virtual void setAccntNo(int a)
{
accntNo = a;
}
virtual void setBalance(double
accntBalance)
{
Balance = accntBalance;
}
virtual int getAccntNo()
{
return accntNo;
}
virtual double getBalance()
{
return Balance;
}
virtual void Deposit(double d)
{
Balance += d;
}
virtual bool Withdraw(double d)
{
if (Balance > d)
{
Balance -=
d;
return
true;
}
else
return
false;
}
};
class Account_Check :public Account
{
private:
double serviceCharges;
double interestRate;
int minbal;//minimum balance
DateType doop;//date of opening
Client_information c;
public:
Account_Check()
{
}
Account_Check(double s, double i, int m,
DateType d, Client_information cl)
{
serviceCharges = s;
interestRate = i;
minbal = m;
doop = d;
c = cl;
}
void setinterestRate(double d)
{
interestRate = d;
}
void setserviceCharges(double d)
{
serviceCharges = d;
}
void setMinbal(int b)
{
minbal = b;
}
int getMinbal()
{
return minbal;
}
double getserviceCharges()
{
return
serviceCharges;
}
double getinterestRate()
{
return interestRate;
}
bool checkBal()
{
if (Balance <
minbal)
return
true;
else
return
false;
}
//deducting service charges
void updateservicecharges()
{
Balance = Balance -
serviceCharges;
}
// adding interest
void updateInteresetBalance()
{
Balance = Balance + (Balance
* (interestRate / 100));
}
//full output
void Display()
{
cout << "\nAccount
Number\t:\t" << accntNo;
c.print();
cout << "\nDate of
Opening\t:\t";
doop.printDate();
cout <<
"\nBalance\t:\t" << Balance << endl;
}
};
int main()
{
//input client information
string fn, ln;
cout << "\nEnter first Name\t:\t";
cin >> fn;
cout << "\nEnter Last Name\t:\t";
cin >> ln;
Client_information c(fn, ln);
//enter date of opening
DateType d;
d.inputDate();
//account information
Account_Check a(2.5, 3.0, 5000, d, c);
cout << "\nEnter Account
Number\t:\t";
int an;
cin >> an;
a.setAccntNo(an);
cout << "\nEnter Balance\t:\t";
int b;
cin >> b;
a.setBalance(b);
a.Display();
int w, dp;
//deposit Amount
cout << "\nEnter Amount to
Deposit\t:\t";
cin >> dp;
a.Deposit(dp);
a.updateservicecharges();
a.updateInteresetBalance();
a.Display();
3. Create a class Client Information, inherited from the class personType with an additional data member to store Emirates ID, Age, date of birth. (Use the class dateType to store the date of birth. Add appropriate constructors and methods to initialize, access, and manipulate the data members. Write a main function to test the classes Make a record of 10 customer's account using Arrays.
answer in one single code.
#include<iostream>
using namespace std;
class Client_information
{
private:
string firstname;//private hide the details from
main class
string lastname;
public:
//default constructor
Client_information() {}
//parameterized constructor
Client_information(string n, string a)
{
firstname = n;
lastname = a;
}
//getter function
string getFName()
{
return firstname;
}
string getlname()
{
return lastname;
}
//setter function
void SetfName(string n)
{
firstname = n;
}
void SetAdd(string n)
{
lastname = n;
}
//output
void print()
{
cout << "\nFirst
Name\t:\t" << firstname;
cout << "\nLast
Name\t:\t" << lastname;
}
};
//date data type using class
class DateType
{
private:
int dd;
int mm;
int yy;
public:
DateType()
{
dd = 1;
mm = 1;
yy = 2000;
}
DateType(int d, int m, int y)
{
dd = d;
mm = m;
yy = y;
}
void setDate(int d, int m, int y)
{
dd = d;
mm = m;
yy = y;
}
void setDay(int d)
{
dd = d;
}
void setMonth(int m)
{
mm = m;
}
void setYear(int y)
{
yy = y;
}
int getDay()
{
return dd;
}
int getMonth()
{
return mm;
}
int getYear()
{
return yy;
}
void inputDate()
{
cout << "\nEnter
Year\t:\t";
cin >> yy;
cout << "\nEnter
Month\t:\t";
cin >> mm;
while (mm < 1 ||
mm>12)// checking month from 1-12
{
cout
<< "\n Invalid Month";
cout
<< "\nEnter Month(1-12)\t:\t";
cin
>> mm;
}
cout << "\nEnter
Day\t:\t";
cin >> dd;
if (mm == 1 == 3 == 5 == 7 ==
8 == 10 == 12)// checking month for 31 days
{
while (dd
< 1 || dd>31)
{
cout << "\n Invalid Day";
cout << "\nEnter
Month(1-31)\t:\t";
cin >> dd;
}
}
else
if (mm ==
4 == 6 == 9 || mm == 11)// checking month for 30 days
{
while (dd < 1 || dd>30)
{
cout << "\n
Invalid Day";
cout << "\nEnter
Month(1-30)\t:\t";
cin >> dd;
}
}
else
{
while (dd < 1 || dd>28)
{
cout <<
"\nInvalid Day";
cout << "\nEnter
Month(1-28)\t:\t";
cin >> dd;
}
}
}
//Print date according to given format
void printDate()
{
cout << mm << "/"
<< dd << "/" << yy;
}
};
class Account
{
protected:
int accntNo;//protected is example of data
abstraction
//using object of another class
double Balance;
//default Constructor
public:
Account()
{
accntNo = 0;
Balance = 0;
}
//parametrized constructor overloading
concept(polymorphism)
Account(int c, double b)
{
accntNo = c;
Balance = b;
}
//setter function
virtual void setAccntNo(int a)
{
accntNo = a;
}
virtual void setBalance(double
accntBalance)
{
Balance = accntBalance;
}
virtual int getAccntNo()
{
return accntNo;
}
virtual double getBalance()
{
return Balance;
}
virtual void Deposit(double d)
{
Balance += d;
}
virtual bool Withdraw(double d)
{
if (Balance > d)
{
Balance -=
d;
return
true;
}
else
return
false;
}
};
class Account_Check :public Account
{
private:
double serviceCharges;
double interestRate;
int minbal;//minimum balance
DateType doop;//date of opening
Client_information c;
public:
Account_Check()
{
}
Account_Check(double s, double i, int m,
DateType d, Client_information cl)
{
serviceCharges = s;
interestRate = i;
minbal = m;
doop = d;
c = cl;
}
void setinterestRate(double d)
{
interestRate = d;
}
void setserviceCharges(double d)
{
serviceCharges = d;
}
void setMinbal(int b)
{
minbal = b;
}
int getMinbal()
{
return minbal;
}
double getserviceCharges()
{
return
serviceCharges;
}
double getinterestRate()
{
return interestRate;
}
bool checkBal()
{
if (Balance <
minbal)
return
true;
else
return
false;
}
//deducting service charges
void updateservicecharges()
{
Balance = Balance -
serviceCharges;
}
// adding interest
void updateInteresetBalance()
{
Balance = Balance + (Balance
* (interestRate / 100));
}
//full output
void Display()
{
cout << "\nAccount
Number\t:\t" << accntNo;
c.print();
cout << "\nDate of
Opening\t:\t";
doop.printDate();
cout <<
"\nBalance\t:\t" << Balance << endl;
}
};
int main()
{
//input client information
string fn, ln;
cout << "\nEnter first Name\t:\t";
cin >> fn;
cout << "\nEnter Last Name\t:\t";
cin >> ln;
Client_information c(fn, ln);
//enter date of opening
DateType d;
d.inputDate();
//account information
Account_Check a(2.5, 3.0, 5000, d, c);
cout << "\nEnter Account
Number\t:\t";
int an;
cin >> an;
a.setAccntNo(an);
cout << "\nEnter Balance\t:\t";
int b;
cin >> b;
a.setBalance(b);
a.Display();
int w, dp;
//deposit Amount
cout << "\nEnter Amount to
Deposit\t:\t";
cin >> dp;
a.Deposit(dp);
a.updateservicecharges();
a.updateInteresetBalance();
a.Display();
3. Create a class Client Information, inherited from the class personType with an additional data member to store Emirates ID, Age, date of birth. (Use the class dateType to store the date of birth. Add appropriate constructors and methods to initialize, access, and manipulate the data members. Write a main function to test the classes Make a record of 10 customer's account using Arrays.