Assume the input data is structured as follows: first there is a non-negative integer specifying the number of employee timesheets to be read in. This is followed by data for each of the employees. The first number for each employee is an integer that specifies their pay per hour in cents. Following this are 5 integers, the number of hours they worked on each of the days of the workweek. Given this data, and given that an int variable total has been declared, write a loop and any necessary code that reads the data and stores the total payroll of all employees in total. Note that you will have to add up the numbers worked by each employee and multiply that by that particular employee's pay rate to get the employee's pay for the week-- and sum those values into total.

Respuesta :

Limosa

Answer:

int employees;   //set integer type variable

int a,b;     //set two integer type variable

int wage=0;   //initialize integer type variable

int hours=0;   //initialize integer type vcariable

total=0;    

cin >> employees;    //get input from the user

for (a=1; a<=employees; a++){     //set for loop

cin >> wage;     //get input from the user

for (b=1; b<=5; b++){    //set for loop

cin >> hours;    //get input from the user

total += hours * wage;    //perform multiplication

}

}

Explanation:

Here, we define four integer type variable "a", "b", "wage" "hour" and assign value in "wage" to 0 and "hours" to 0.

Then, we get input from the user in the variable "employees".

Then, we set the for loop and pass the condition inside it we get input from the user in the variable "wage".

Then, again we set the for loop and pass the condition inside it we get input from the user in the variable "hours".

Then, we perform addition and the multiplication.