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

plz do a,b and c CSC 126 Spring 2016 Final B 2 points) suppose the weekly bours

ID: 3581145 • Letter: P

Question



plz do a,b and c

CSC 126 Spring 2016 Final B 2 points) suppose the weekly bours for a -time employees are stored in a two-dimensional array. Each row records an employee's work hours for seven days with seven columns. For example, the following array sores the work hours for 4 employees. Give a declaration (you don't have to put in the values) for the two-dimensional array above. b b) (5 points) Given the array above, what is printed by the following code? int i, j, sun 0; for i 0; i 4; i++) for (J 4; k 6; j++) sum sun matrix till cout Employee i 1 processed Kendl. cout Weekend Totals sum endli

Explanation / Answer

answer for a:

#include <iostream>

using namespace std;

int main()
{
int hours[4][7] = {0};

return 0;
}

--------------------

answer for b:

It looks like the question is wrongly printed as sum is initialized to 0 inside for loop with 'i'. The output with the given program is below:

Employee 1 processed...

Employee 2 processed...

Employee 3 processed...

Employee 4 processed...

Weekend Totals: 7

Program written is below:

#include <iostream>

using namespace std;

int main()
{
int hours[4][7] = {
{2,4,3,4,5,8,8},
{7,3,5,3,3,4,4},
{3,3,4,3,4,3,2},
{9,3,4,7,3,4,1}
};
int i,j,sum=0;
for(i=0;i<4;i++){
sum=0;
for(j=4;j<6;j++)
sum=sum+hours[i][j];
cout << "Employee " << i+1 << " processed..."<<endl;
  
}
cout << "Weekend Totals: " << sum << endl ;

return 0;
}

The purpose of the program looks to find the total of the weekend for all the employees. I tweaked the program to look like below(just commented sum=0):

#include <iostream>

using namespace std;

int main()
{
int hours[4][7] = {
{2,4,3,4,5,8,8},
{7,3,5,3,3,4,4},
{3,3,4,3,4,3,2},
{9,3,4,7,3,4,1}
};
int i,j,sum=0;
for(i=0;i<4;i++){
//sum=0;
for(j=4;j<6;j++)
sum=sum+hours[i][j];
cout << "Employee " << i+1 << " processed..."<<endl;
  
}
cout << "Weekend Totals: " << sum << endl ;

return 0;
}

and for this program output is:

Employee 1 processed...

Employee 2 processed...

Employee 3 processed...

Employee 4 processed...

Weekend Totals: 34

--------------------------------------

#include <iostream>

using namespace std;

int main()
{
int hours[4][7] = {
{2,4,3,4,5,8,8},
{7,3,5,3,3,4,4},
{3,3,4,3,4,3,2},
{9,3,4,7,3,4,1}
};
int i,j,highest=0;
for(i=0;i<4;i++){
for(j=0;j<7;j++){
if(hours[i][j]>highest)
highest=hours[i][j];
}
}
cout << "Highest number " << highest << endl ;

return 0;
}

output:

Highest number 9