Question: Can you please answer it clearly with an explanation if possible? Q/ Define a class called Person with private members first , and last both

Can you please answer it clearly with an explanation if possible?

Q/ Define a class called Person with private members first, and last both of type string. The class also has the public member functions set(), print(), getFirstName(), getLastName(), and a default parameterized constructor.

Define a class called Product with private members name, code both of type string, price, quantity both of type integer, and the function calculateCost() which calculates the cost of a product (price * quantity). The class also has the public member functions set(), print(ofstream&), getName(), getCode(), getPrice(), getQuentity(), and a default parameterized constructor.

Define a class called Selasperson that publicly inherits the class Person. The class has the private members Id, numberOfProducts both of type integer, salary of type double, productsSold[ ] (an array of type Product and size maxSize = 10), and the member function calculateSalary(). The class also has the public members set(ifstream&), print(ofstream&), and getSalary().

The salary is calculated as 6% of the sum of price * quantity of all products sold.

Implement all member functions of the three classes, enforcing the least privileged principle.

The following driver produces the given sample of output:

ifstream inFile("productIn.txt", ios::in);

ofstream outFile("productOut.txt", ios::out);

int main()

{

Salesperson salespersonsList[10];

int i, noOfSalespersons;

inFile >> noOfSalespersons;

for(i=0; i

salespersonsList[i].set(inFile);

for(i=0; i

salespersonsList[i].print(outFile);

return 0;

}

Sample Input: Content of the text file productIn.txt

3

Lisa Miller 890238 4

Bed BB01 430 4

Mattres BM03 210 5

Quilt BQ02 130 3

Pillow BP01 25 8

Can you please answer it clearly with an explanation if possible? Q/

Bill Wilton 798324 5

Linen BL02 78 6

Quilt BQ02 130 5

Curtains BC03 315 4

Pillow BP01 25 10

Wardrobe BW01 170 2

Dandy Goat 746333 6

Wardrobe BW01 170 1

Mattres BM03 210 2

Pillow BP01 25 4

Curtains BC03 315 5

Quilt BQ02 130 2

Linen BL02 78 4

W AutoSave Off Assignment \#2 - Compatibility Mode - Saved to this PC V File Home Insert Draw Design Layout References Mailings Review View Help Total salary: 201.6 -*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_ Salesperson Name: Bill Wilton Salesperson ID: 798324 Number of products soled: 5 Total salary: 178.08 _*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_ Salesperson Name: Dandy Goat Salesperson ID: 746333 Number of products soled: 6 Total salary: 170.22 -*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_*_

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!