

// C++ program to create a 2D array of working hours for
employee for all week day SUN-SAT with random numbers
// between 0 and 10(exclusive) and calculate the statistics using
this array
#include <iostream>
#include <cstdlib>
#include <ctime>
#include <iomanip>
using namespace std;
// function prototype
void displayEmployee(int workingHours[][7], int numEmployee, int
numDays);
double average_all_employee_all_days(int workingHours[][7], int
numEmployee, int numDays);
double* average_all_employee_per_day(int workingHours[][7], int
numEmployee, int numDays);
double* average_all_day_per_employee(int workingHours[][7], int
numEmployee, int numDays);
int main()
{
srand(time(0));
// Assuming num of employees = 8
// data for the working hours
int workingHours[8][7] ; // 8 employees and 7 weekdays
SUN-SAT
// number of employee and number of days
int numEmployee = 8, numDays = 7;
// array to store the days
string days[] = {"SUN", "MON", "TUE", "WED", "THU", "FRI",
"SAT"};
// loop to fill the array with random working hours between 0 and
10(exclusive)
for(int i=0;i<numEmployee;i++)
{
for(int j=0;j<numDays;j++)
{
workingHours[i][j] = rand()%10; // generates random integer between
0 and 10 (exclusive)
}
}
// display the array
displayEmployee(workingHours, numEmployee, numDays);
// get the average of all employees for all days
double avg = average_all_employee_all_days(workingHours,
numEmployee, numDays);
// get the average for all days per employee
double* avg_per_emp = average_all_day_per_employee(workingHours,
numEmployee, numDays);
// get the average for all employees per day
double* avg_per_day = average_all_employee_per_day(workingHours,
numEmployee, numDays);
cout<<fixed<<setprecision(2);
// display the result
cout<<endl<<"Average of working hours for all employees
for all weekday: "<<avg<<endl;
cout<<endl<<"Average of working hours for all employees
per one day: "<<endl;
for(int i=0;i<numDays;i++)
{
cout<<days[i]<<" :
"<<avg_per_day[i]<<endl;
}
cout<<endl<<"Average of working hours for all
weekday per one employee: "<<endl;
for(int i=0;i<numEmployee;i++)
{
cout<<"Employee "<<(i+1)<<" :
"<<avg_per_emp[i]<<endl;
}
return 0;
}
// function to display the data of the input array for given
number of rows and columns
void displayEmployee(int workingHours[][7], int numEmployee, int
numDays)
{
cout<<left<<setw(20)<<""<<right<<setw(5)<<"SUN"<<right<<setw(5)<<"MON"<<right<<setw(5)<<"TUE"<<right<<setw(5)<<"WED"
<<right<<setw(5)<<"THU"<<right<<setw(5)<<"FRI"<<right<<setw(5)<<"SAT"<<endl;
for(int i=0;i<numEmployee;i++)
{
cout<<right<<setw(15)<<"Employee
"<<left<<setw(5)<<(i+1);
for(int j=0;j<numDays;j++)
cout<<right<<setw(5)<<workingHours[i][j];
cout<<endl;
}
}
// function to calculate the overall average of the array
double average_all_employee_all_days(int workingHours[][7], int
numEmployee, int numDays)
{
double total_hours = 0; // set total hours to 0
// loop over the rows
for(int i=0;i<numEmployee;i++)
{
// loop over the columns
for(int j=0;j<numDays;j++)
{
total_hours += workingHours[i][j]; // add the entry to
total_hours
}
}
return ((double)total_hours)/(numEmployee*numDays); // return
the average
}
// function to calculate the average for each column
double* average_all_employee_per_day(int workingHours[][7], int
numEmployee, int numDays)
{
double *avg = new double[numDays]; // create the array of size
equal to numDays
// loop over the columns
for(int i=0;i<numDays;i++)
{
avg[i] = 0; // set the ith entry in avg to 0
// loop over the rows
for(int j=0;j<numEmployee;j++)
avg[i] += workingHours[j][i]; // add the (j,i) entry to
avg(i)
avg[i] = avg[i]/numEmployee; // calculate the average per day
}
return avg;
}
// function to calculate the average for each row
double* average_all_day_per_employee(int workingHours[][7], int
numEmployee, int numDays)
{
double *avg = new double[numEmployee]; // create the array of size
equal to numEmployee
// loop over the rows
for(int i=0;i<numEmployee;i++)
{
avg[i] = 0; // set the ith entry of avg to 0
// loop over the columns
for(int j=0;j<numDays;j++)
avg[i] += workingHours[i][j]; // add the (i,j) entry to
avg(i)
avg[i] = avg[i]/numDays; // calculate the average for ith
employee
}
return avg;
}
//end of program
Output:

Write a C++ program that calculates the working hours of multiple employees during a weekday. The...
using C# Write a program which calculates student grades for multiple assignments as well as the per-assignment average. The user should first input the total number of assignments. Then, the user should enter the name of a student as well as a grade for each assignment. After entering the student the user should be asked to enter "Y" if there are more students to enter or "N" if there is not ("N" by default). The user should be able to...
Project DescriptionWrite a program that calculates the average number of days a company's employees are absent during the year and outputs a report on a file named "employeeAbsences.txt".Project SpecificationsInput for this project:the user must enter the number of employees in the company.the user must enter as integers for each employee:the employee number (ID)the number of days that employee missed during the past year.Input Validation:Do not accept a number less than 1 for the number of employees.Do not accept a negative...
Write a C program that will calculate the gross pay of a set of employees. The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay and then outputs a table in the following format. Column alignment, leading zeros in Clock#, and zero suppression in float fields is important. Use 1.5 as the overtime pay...
C# : Write a program which calculates Sum, Average of a given array. Array must be initialized using initializer. use loops to calculate the same display the output.
in C language we need to find the following :
EXERCISE 3: 1. Write the definition of a structure named employee that contains character array members for an employee's first and last names, an int member for the employee's age, a char member that contains 'M' or 'F' for the employee's gender, and a double member for the employee's hourly salary. 2. Using the above mentioned definition, write a C program that asks a user to enter the values of...
Please include function in this program
Write a C program that will calculate the gross pay of a set of employees utilizing pointers instead of array references. You program should continue to use all the features from past homeworks (functions, structures, constants, strings). The program should prompt the user to enter the number of hours each employee worked. When prompted, key in the hours shown below. The program determines the overtime hours (anything over 40 hours), the gross pay and...
in C++ Write a program which uses the following arrays: empID: An array of 7 integers to hold employee identification numbers. The array should be initialized with the following values: 1, 2, 3, 4, 5, 6, 7. Hours: an array of seven integers to hold the number of hours worked by each employee. payRate: an array of seven doubles to hold each employee’s hourly pay rate. Wages: an array of seven doubles to hold each employee’s gross salary. The program...
Write a C program that deal with employees’ salaries in a company, as follows: Define an integer array named salaries of size 100 Initialize all array elements with zeros Fill all array elements with random numbers within a range of 350 until 3000 (all inclusive) by using built-in-function rand() and srand() Develop the following functions and call them from the main program: avgSalary(), a function that receives the array and its size as parameters and returns the average salary in...
Write a C++ program that simulates a lottery game. Your program should use functions and arrays. Define two global constants: - ARRAY_SIZE that stores the number of drawn numbers (for example 5) -MAX_RANGE that stores the highest value of the numbers ( for example 9 ) The program will use an array of five integers named lottery, and should generate a random number in the range of 0 through 9 for each element of the array. The user should enter...
part1 7.4 Create a new file (in Dev C++) and save it Write a program that uses parallel arrays to store payroll data for 5 employees. The program should display each employee name and then prompt for hours and rate. Calculate and store gross pay for each employee. After the data has been entered for all employees, display each employee's ID, name, hours, rate and gross pay as a table. Use the following arrays: arrEmpIDs: array of five integers, initialized...