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

Who here is matlab god? I would be really appreciate it for your help :) 1. (30

ID: 3681428 • Letter: W

Question

Who here is matlab god? I would be really appreciate it for your help :)

1. (30 pts) Create a 10 by 2 array called pay record. The first column stores information of work hours of ten employees in one week, and the second column stores the information of hourly pay (S/hr). Your program will calculate the payment to each employee and the total payment of the week. Case I assume nobody works overtime; therefore payment is simply hours 'rate. Specification: the first column consists of random integers between 20 and 40 (hours), and second column consists integers between 10 and 20 (S per hour). Calculate the payment to each employee, without loops, and add this information as the third column of the original array. Also calculate the total payment to the 10 employees. You may use loops for formatted output Case Il: assume there are some who works overtime, and the overtime pay for hours beyond 40 hours is at 2 times of the regular rate. Specification: the first column consists of random integers between 20 and 60 (hours), and second column consists integers between 10 and 20 (S per hour). Calculate the payment to each employee, with or without loops, and add this information as the third column of the original array. Also calculate the total payment to the 10 employees.

Explanation / Answer

Program:

disp('case I: No Overtime Pay');
disp('*************************************************');
disp('hours rate($/hr) pay($)');
pay_record=zeros(10,2);
total_payment=zeros(10,1);
pay_record(:,1)=randi([20,40],1,10);
pay_record(:,2)=randi([10,20],1,10);
total_payment(:,1)=pay_record(:,1).*pay_record(:,2);
total=[pay_record(:,1) pay_record(:,2) total_payment(:,1)];
disp(total);
disp('the total payment for all employees is $');
k=sum(total_payment);
disp(k);

disp('case I: With Overtime Pay');
disp('*************************************************');
disp('hours rate($/hr) pay($)');
pay_record(:,1)=randi([20,60],1,10);
pay_record(:,2)=randi([10,20],1,10);
if(pay_record(:,1)>40)
total_payment(:,1)=40.*pay_record(:,2);
total_payment(:,1)=total_payment(:,1)+(pay_record(:,1)-40).*2.*pay_record(:,2);
else
total_payment(:,1)=pay_record(:,1).*pay_record(:,2);
end
total=[pay_record(:,1) pay_record(:,2) total_payment(:,1)];
disp(total);
disp('the total payment for all employees is $');
k=sum(total_payment);
disp(k);

Result:

case I: No Overtime Pay
*************************************************
hours rate($/hr) pay($)
30 12 360
39 12 468
33 17 561
40 19 760
25 13 325
34 18 612
26 17 442
34 10 340
34 16 544
21 14 294

the total payment for all employees is $
4706

case I: With Overtime Pay
*************************************************
hours rate($/hr) pay($)
57 11 627
20 17 340
38 15 570
37 11 407
38 13 494
51 16 816
33 12 396
52 18 936
39 12 468
21 20 420

the total payment for all employees is $
5474