In: Mechanical Engineering
Write a Matlab Code for the following:
A co-op is paid a $15.00 hourly wage up to 20 hours per week. In addition, any hours over 20, the co-op collects an overtime wage that is 1.5 times greater, and any hours over 30, 2.0 times greater. Using an in-else statement, write a code that calculates the co-op’s gross paycheck for: a) 15 hours worked b) 28 hours worked c) 35 hours worked
a) 15 hours worked.
clear,clc
x = 15;
wage = 15;
normal_pay = wage*20;
if(x<=20)
pay = wage*x;
disp('The gross paycheck is $')
disp(pay)
elseif (x>20) & (x<=30)
e_hours = x-20;
e_pay = e_hours*1.5*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
elseif (x>30)
e_hours= x-30;
normal_pay= 525;
e_pay = e_hours*2.0*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
end
b) 28 hours worked.
clear,clc
x = 28;
wage = 15;
normal_pay = wage*20;
if(x<=20)
pay = wage*x;
disp('The gross paycheck is $')
disp(pay)
elseif (x>20) & (x<=30)
e_hours = x-20;
e_pay = e_hours*1.5*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
elseif (x>30)
e_hours= x-30;
normal_pay= 525;
e_pay = e_hours*2.0*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
end
c) 35 hours worked.
clear,clc
x = 35;
wage = 15;
normal_pay = wage*20;
if(x<=20)
pay = wage*x;
disp('The gross paycheck is $')
disp(pay)
elseif (x>20) & (x<=30)
e_hours = x-20;
e_pay = e_hours*1.5*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
elseif (x>30)
e_hours= x-30;
normal_pay= 525;
e_pay = e_hours*2.0*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
end
you can also use the bellow program for multiple inputs
clear,clc
x = input('Enter working hours')
wage = 15;
normal_pay = wage*20;
if(x<=20)
pay = wage*x;
disp('The gross paycheck is $')
disp(pay)
elseif (x>20) & (x<=30)
e_hours = x-20;
e_pay = e_hours*1.5*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
elseif (x>30)
e_hours= x-30;
normal_pay= 525;
e_pay = e_hours*2.0*wage;
pay = normal_pay + e_pay;
disp ('The gross paycheck for $')
disp(pay)
end