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

Please include everything needed to compile and make sure it does compile. I am

ID: 3536457 • Letter: P

Question

Please include everything needed to compile and make sure it does compile. I am using C++ and C++ builder XE4.

Exercise 5.1

Impliment all member functions of the following class:

Class person

{

Public:

Person()

Person(string name, int page);

Void get_name() const;

Void get_age() const;

Private:

String name;

Int age; // 0 if unknown

};

Exercise 5.2

Implement a class PEmployee that is just like the employee class except that it stores an object of type person as developed in exercise 5.1

Class PEmployee

{

Public:

PEmployee();

PEmployee(string employee_name, double initial_salary);

Void set_salary(double new_salary);

Double get_salary() const;

String get_name() const;

Private:

Person person_data;

Double salary;

};

Exercise 5.4

Implement a class account. An account has a balance, functions to add and withdraw money, and a function to query the current balance. Charge a $5 penalty if an attempt is made to withdraw more money than is in the account.

Explanation / Answer

#include<iostream>

#include<string>

#include<iomanip>

using namespace std;

Class person

{

Private:

string name;

int age; // 0 if unknown

Public:

Person()

Person(string name, int page);

Void get_name() const;

Void get_age() const;


};

Class PEmployee

{

Public:

PEmployee();

PEmployee(string employee_name, double initial_salary);

Void set_salary(double new_salary);

Double get_salary() const;

String get_name() const;

Private:

person person_data;

Double salary;

};


PEmployee::PEmployee();

{

person_data;

salary=0.0;

}

PEmployee::PEmployee(string employee_name, double initial_salary);

{

person_data(employee_name,initial_salary);

}

PEmployee::void set_salary(double new_salary)

{

salary=new_salary;

}

PEmployee::double get_salary()

{

return salary;

}

PEmployee::string get_name()

{

return person_data.name;

}

person::person( )

{

cout <<"Enter person name<default>: " ;

getline(cin,name,' ');

age=0;

}

person::person(string inputName,int inputAge)

{

age=inputAge;

name=inputName;

}

person::void get_name()

{

cout <<"Enter person name"<<endl;

getline(cin,name,' ');

}

person::void get_age()

{

cout<<"Enter person's age"<<endl;

cin>>age;

}