Ask Question
17 July, 05:58

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.

+5
Answers (2)
  1. 17 July, 07:40
    0
    The structure of the following program

    int numberOfTimesheets;

    int centsPerHour = 0;

    int hoursWorked;

    total = 0;

    numberOfTimesheets = stdin. nextInt ();

    for (int i = 1; i < = numberOfTimesheets; i++)

    {

    hoursWorked = 0;

    centsPerHour = stdin. nextInt ();

    for (int ii = 1; ii < = 5; ii++)

    {

    hoursWorked = hoursWorked + stdin. nextInt ();

    }

    total = total + (hoursWorked * centsPerHour);

    }
  2. 17 July, 08:58
    0
    The structure of the following program:

    int employees;

    int a, b;

    int wage=0;

    int hours=0;

    total=0;

    cin >> employees;

    for (a=1; a<=employees; a++) {

    cin >> wage;

    for (b=1; b<=5; b++) {

    cin >> hours;

    total + = hours * wage;

    }

    }

    Explanation:

    Firstly, we set non-negative integer type variables "a" and "b", than set two more integer type variables "wage" and "hours", after that gets input in the variable "employees", than set for loop which is starts from 1 and ends according to the length of the employees and gets input in the variable wages and then repeat this process with hour, after all we sum those value in total.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question ✅ “Assume the input data is structured as follows: first there is a non-negative integer specifying the number of employee timesheets to be ...” in 📘 Computers and Technology if you're in doubt about the correctness of the answers or there's no answer, then try to use the smart search and find answers to the similar questions.
Search for Other Answers