Question
ANSWER IN C++ 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
ANSWER IN C++
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
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started