Question

In: Mechanical Engineering

Write a Matlab Code for the following: A co-op is paid a $15.00 hourly wage up...

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

Solutions

Expert Solution

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


Related Solutions

Write a program that calculates pay for either hourly paid workers or salaried workers. Hourly paid...
Write a program that calculates pay for either hourly paid workers or salaried workers. Hourly paid workers are paid their hourly pay rate times the number of hours worked. Salaried workers are payed their regular salary plus any bonus they may have earned. The program should declare two structures for the following data: • Hourly Paid ◦HoursWorked ◦ HourlyRate • Salaried ◦ Salary ◦ Bonus The program should also declare a structure with two members. Each member should be a...
If firms increase the hourly wage paid to all workers then (all else the same) this...
If firms increase the hourly wage paid to all workers then (all else the same) this will tend to: Group of answer choices increase the price of the goods sold by the firms because of a decrease in supply. increase the price of the goods sold by the firms because of an increase in supply. decrease the price of the goods sold by the firms because of a decrease in supply. decrease the price of the goods sold by the...
Use Matlab to write the following 1. Write code to determine whether a year is a...
Use Matlab to write the following 1. Write code to determine whether a year is a leap year. Use the mod function. The rules for determining leap years in the Gregorian calendar are as follows: All years evenly divisible by 400 are leap years. Years evenly divisible by 100, but not by 400, are not leap years. Years divisible by 4, but not by 100, are leap years. All other years are not leap years. For example, the years 1800,...
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less....
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less. A grocery chain offers discount rates to companies that have at least 30 employees who earn the prevailing minimum wage or less. Complete parts​ (a) through​ (c) below. ​(a) Company A has 299 employees. What is the probability that Company A will get the​ discount?
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less....
About 5​% of hourly paid workers in a region earn the prevailing minimum wage or less. A grocery chain offers discount rates to companies that have at least 30 employees who earn the prevailing minimum wage or less. Complete parts​ (a) through​ (c) below. ​(a) Company A has 287 employees. What is the probability that Company A will get the​ discount? ​(Round to four decimal places as​ needed.) ​(b) Company B has 501 employees. What is the probability that Company...
write the code in MATLAB with comments and show the inputs and results of the code...
write the code in MATLAB with comments and show the inputs and results of the code for the question below. Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds that was recorded using your phone), then take Fourier transform of the signal (probably FFT).
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio...
show the MATLAB Code with comments and Write an .m file in MATLAB, that records audio (you can record your own voice for 20 seconds), takes Fourier transform of the signal (probably FFT).
write a matlab code to simulate fiber optics communication system on matlab simulink
write a matlab code to simulate fiber optics communication system on matlab simulink
I'm new in MATLAB and I have to write a code in MATLAB which converts a...
I'm new in MATLAB and I have to write a code in MATLAB which converts a number from one base to another without using base2base, etc
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your...
Write a MATLAB code to obtain the following. Keep your code commented whenever required. Copy your source code and command widow outcomes and screen shots of any plots in your solution. Develop three functions for temperature-conversion. Create a function called F_to_K that converts and return temperatures in Fahrenheit to Kelvin and store results in ‘F_to_K2.txt’. Create a function called C_to_R that converts and return temperatures in Celsius to Rankine and store results in ‘C_to_R2.txt’. Create a function called C_to_F that...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT