MATLAB Code:
% MATLAB Script that reads employee working hours data and calculates average working hours
clc;
clear;
% Opening file in read mode
filehandle = fopen("weeklyHours.txt", "r");
% Array to hold data
employeeHours = {};
% For iterating over each employee
i = 1;
j = 1;
% Reading names from file
if(~feof(filehandle))
% Fetching a line of data
line = fgetl(filehandle);
% Splitting on space
cols = strsplit(line);
for i = 1:2:18
% Forming name
name = [cols{i} ' '
cols{i+1}];
% Storing name
employeeHours{j,1} = name;
employeeHours{j,2} = [];
employeeHours{j,3} = 0;
j = j+1;
endfor
endif
% Reading names from file
while(~feof(filehandle))
j = 1;
% Fetching a line of data
line = fgetl(filehandle);
% Splitting on space
cols = strsplit(line);
% Iterating over each employee
for i = 1:length(employeeHours)
% Storing hours worked
employeeHours{j,2} =
[employeeHours{j,2} str2num(cols{i})];
j = j+1;
endfor
endwhile
j = 1;
% Calculating average working hours
for i = 1:length(employeeHours)
% Forming name
employeeHours{j,3} = sum(employeeHours{j,2}) / 7.0;
j = j+1;
endfor
% Closing file
fclose(filehandle);
% Displaying data
for j = 1:i
% Printing formatted String of data
fprintf("\n %s average hours worked: %.2f ",
employeeHours{j, 1}, employeeHours{j, 3});
endfor
fprintf("\n\n");
_______________________________________________________________________________________________
Sample Output:
Help writing MatLab code Lab Assignment 5-Employees Average Hours CSCI 251 Problem Statement Suppose the weekly...
In C++ Please please help.. Assignment 5 - Payroll Version 1.0 In this assignment you must create and use a struct to hold the general employee information for one employee. Ideally, you should use an array of structs to hold the employee information for all employees. If you choose to declare a separate struct for each employee, I will not deduct any points. However, I strongly recommend that you use an array of structs. Be sure to read through Chapter...
CSCI 112 C Programming Database Lab This lab will focus on the use and manipulation of structures. Each section of the lab should be designed within its own function, passing parameters as necessary. You are to construct a C program, database.c, that will retrieve and manipulate a company's payroll database, payfile.txt. The data for each employee should be read into a structure containing the following field identifiers: first : 7 characters maximum, initial : 1 character maximum, last : 9...
I am really struggling with this assignment, can anyone help? It is supposed to work with two files, one that contains this data: 5 Christine Kim # 30.00 3 1 15 Ray Allrich # 10.25 0 0 16 Adrian Bailey # 12.50 0 0 17 Juan Gonzales # 30.00 1 1 18 J. P. Morgan # 8.95 0 0 22 Cindy Burke # 15.00 1 0 and another that contains this data: 5 40.0 15 42.0 16 40.0 17 41.5...
PLEASE HELP!!!! 1) CONDITIONAL FORMATTING - Add conditional formatting to the Hours Worked field data so that any hours worked greater than 8 will show in white font with a dark fill. 2) DATABASE FUNCTION - Create a database function in cell E5 that calculates the average hours worked by males in Dept. No. 2. If criteria are needed, start in cell E1. 3) VLOOKUP - In the Department field (column D) use the VLOOKUP function to place the appropriate...