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

matlab Write a MATLAB code that loads Income_Info.txt and determines the followi

ID: 2080941 • Letter: M

Question


matlab

Write a MATLAB code that loads Income_Info.txt and determines the following WRITE A WHILE LOOP that calculates the following: a) Pay for each day of the week (hourly rate x number of hours/week + Tips). b) Total pay for the week WRITE A WHILE/IF/ELSEIF LOOP to determine a) What is the highest weekly pay? b) Which employee received the highest pay for the week (output employee number) c) What is the lowest weekly pay? d) Which employee received the lowest pay for the week (output employee number) WRITE A WHILE LOOP to calculate the total pay for the month (using 4 weeks/month) Assume all the employees working at the Cara receive an extra $4000 in education support per year. WRITE A WHILE/IF/ELSEIF LOOP to determine the number of employees with an annual income that falls below the poverty tax line. Use the 2012 one-person threshold of $11, 720. WRITE A WHILE LOOP considering ONLY those employees that are above the poverty line, what is the (a) mean and (b) standard deviation of their income? Mean: x = sigma^R x_i Standard Deviation: sigma = Squareroot 1/n sigma^n (x_i + x)^2

Explanation / Answer

Since solution is asked for question 2, 4 and 5 and they are different questions, I am providing the code for 2 with all its 4 different sub-parts.

Solution:

First create the text file income_info.txt and the file contains 3 columns.

Col 1---> Employee Code

Col 2 --> Hourly Fixed Pay

Col 3 --> Work Hour Daily

Col 4 -->Personal Tips Weekly

income_info.txt

17052 20 8 12

17053 20 8 18

17054 20 8 10

Then import the file in MATLAB.

THE M SCRIPT FILE IS GIVEN BELOW:

clc
disp('The total number of employees working in the cafe is')
disp(length(income_info(:,1)))
m=length(income_info(:,1)); % It stores the information about number of employees working=Number of rows
earning=zeros(m,1); % It will store the information about the earning of each employee
disp(length(income_info(1,:))) %Max row and col length for the income_info matrix

for i=1:m
earning(i,1)=income_info(i,2)*income_info(i,3)+income_info(i,4);
end
%After this poing all the employee's salary of the week has been calculated

% 2(a)and 2 (b) Display of Higherst Weekly Pay & corresponding empolyee
% number
if(earning(1,1)> earning(2,1))
if(earning(1,1)> earning(3,1))
disp('Highest Salary is')
disp(earning(1,1))
disp('The employee earning highest salary is')
disp(income_info(1,1))
end
end
  
if(earning(2,1)> earning(1,1))
if(earning(2,1)> earning(3,1))
disp('Highest Salary is')
disp(earning(2,1))
disp('The employee earning highest salary is')
disp(income_info(2,1))
end
end
  
if(earning(3,1)> earning(2,1))
if(earning(3,1)> earning(1,1))
disp('Highest Salary is')
disp(earning(3,1))
disp('The employee earning highest salary is')
disp(income_info(3,1))
end
end
  
% 2(c) & 2(d)
  
if(earning(1,1)< earning(2,1))
if(earning(1,1)< earning(3,1))
disp('Lowest Salary is')
disp(earning(1,1))
disp('The employee earning lowest salary is')
disp(income_info(1,1))
end
end
  
if(earning(2,1)< earning(1,1))
if(earning(2,1)< earning(3,1))
disp('Lowest Salary is')
disp(earning(2,1))
disp('The employee earning lowest salary is')
disp(income_info(2,1))
end
end
  
if(earning(3,1)< earning(2,1))
if(earning(3,1)< earning(1,1))
disp('Lowest Salary is')
disp(earning(3,1))
disp('The employee earning lowest salary is')
disp(income_info(3,1))
end
end
  

  
The Output:

The total number of employees working in the cafe is
3

4

Highest Salary is
178

The employee earning highest salary is
17053

Lowest Salary is
170

The employee earning lowest salary is
17054