CMPSC 200 Programming for Engineers with MATLAB Lab 6
Sottile – Spring 2016 CMPSC 200 Programming for Engineers with MATLAB Lab 6 Instructions: Create a single script (.m file) to solve this problem. Unless directed otherwise, use meaningful variable names for each variable; do not use the default variable ans to store your results. Suppress your output for every calculation or allocation with a semi-colon; you may only use print commands to print output. Please remember to follow the programming style sheet on ANGEL. When complete, please submit your code to the dropbox on ANGEL; the graders will run it to view your output. Name your file like this: username_lab6.m (example: bjs5332_lab6.m). Your submission must be a single .m file. Problem 1 (10 points) Permanent employees are generally classified under two different compensation schemes: wage payroll (“wage”) employees, and salaried employees. Wage employees receive an hourly rate for the time they work, and are eligible for overtime on the time they work over the specified “fulltime hours”. Salaried employees receive a fixed paycheck regardless of the number of hours worked; as such, they are ineligible for overtime. Consider a company that compensates their wage employees as such: Full-Time Hours: 40 Normal Hourly Rate: $23/hour Overtime Multiplier: 1.5 (for time over 40 hours) Write a program that a payroll clerk could use to figure out the gross pay for their employees. Calculate the pay (printed only to 2 decimal places) for wage employees; include a notification if a wage employee will be receiving overtime pay. Since a salaried employee’s pay is fixed, there would be no reason to need to calculate it – a simple statement stating such to the user observing this fact will suffice. Prompt the user with a menu to choose “Wage Employee” or “Salaried Employee,” then use a switch to examine each of those cases as appropriate. Try to mirror the sample results I’ve included on the second page of this document. Emulate the behavior of a do while loop in MATLAB to ensure the program runs at least once; the program should run until the user enters a sentinel value of −1. Only enter numbers when you check if the program should terminate. Hints: (1) For wage employees, overtime only applies to the time worked over the full-time hours. (2) do while loops are unavailable in MATLAB, but we discussed how to emulate their behavior in Lecture 16 using while loops. (3) Only enter numbers to check if the loop should stop, otherwise the program will yield errors when you check the stopping criteria. (4) You might find it useful to nest an if statement into one of your switch cases. Sottile – Spring 2016 Sample Results: Sample Menu: Sample Run I/O: How many hours did employee work?: 30 Gross pay is $690.00 Do you wish to continue? Enter -1 to terminate, otherwise the program will continue: 5 How many hours did employee work?: 50 Employee will receive overtime Gross pay is $1265.00 Do you wish to continue? Enter -1 to terminate, otherwise the program will continue: 2 Salaried employees don't enter hours! Do you wish to continue? Enter -1 to terminate, otherwise the program will continue: -1 Goodbye! Note: The selections on the menu needed to generate this output are: Wage Employee, Wage Employee, Salaried Employee
10 years ago
Purchase the answer to view it

- cmpsc_200_programming_for_engineers_with_matlab_lab_6.rar