Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Consider a class Employee with data members: age (an integer), id (an integer) and salary (a float), and their corresponding member functions as follows: class

Consider a class Employee with data members: age(an integer), id (an integer) and salary (a float), and their corresponding member functions as follows:

class Employee

{

private:

int age;

int id;

float salary;

public:

Employee( ); // default constructor: age=0, id=0, and salary=0

void setAge(int x); // let age = x

void setId(int x); // let id = x

void setSalary(float x); // salary = x

int getAge( ); // return age

int getId( ); // return id

float getSalary( ); // return salary

};

You need to provide the definition of the default constructor and the first three member functions (setAge, setId and setSalary) inside the scope defined by the brackets of class Employee and other three member functions (getAge, getId, and getSalary) outside the scope defined by the brackets of class Employee, as shown in the following skeleton:

class Employee

{

Employee( )

{ ..... }

void setAge(int x)

{ ......... }

void setId(int x)

{ ......... }

void setSalary(float x)

{ ......... }

};

int Employee::getAge( )

{

.....

}

int Employee::getId( )

{

....

}

float Employee::getSalary( )

{

......

}

Write a main routine in which you create an 2-D array of Employee x[2][3]. Set the values for all the elements of the array as follows:

Age

Id

Salary

x[0][0]

30

111

30000

x[0][1]

31

112

31000

x[0][2]

32

113

32000

x[1][0]

33

114

33000

x[1][1]

34

115

34000

x[1][2]

35

116

35000

Then, pass the array to a function, PrintEmployee(arg1, arg2, arg3), in which arg1 should be the array of Employee, arg2 is the length of the first dimension of the array (=2 in this case), and arg3 is the length of the second dimension of the array (=3 in this case). In PrinteEmployee(arg1, arg2, arg3), write a for loop to print out the information of each employee (in this case, we have six employees in total). In addition, an average age and an average salary should be also printed out.

The skeletons of the main( ) and PrintEmployee() are as follows:

void main( )

{

// create an array of Employee with two elements

..

// set the values for all the elements of the array by using public member functions

// call PrintEmployee( ) with a proper parameter list

PrintEmplyee( arg1, arg2, arg3);

}

void PrintEmployee(arg1, arg2, arg3)

{

// for loop

.

// print out an average age and an average salary

.

}

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Autonomous Database In Enterprise Architecture

Authors: Bal Mukund Sharma, Krishnakumar KM, Rashmi Panda

1st Edition

1801072248, 978-1801072243

More Books

Students also viewed these Databases questions

Question

Find the derivatives of the function S 4t t + 1 -2

Answered: 1 week ago

Question

What is the meaning and definition of E-Business?

Answered: 1 week ago

Question

4. Describe the role of narratives in constructing history.

Answered: 1 week ago

Question

1. Identify six different types of history.

Answered: 1 week ago