Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Program in python: Salary calculator. In this problem, you are asked to write a Python program to calculate the daily salary for employees of a

Program in python:

Salary calculator. In this problem, you are asked to write a Python program to calculate the daily salary for employees of a small software company. An employee of the company may be part of the managerial staff, the technical staff, or the janitorial staff. The hours of employment and rate of pay depend on the employees category, as summarized below: The managerial staff are required to work 10 hours per day at the rate of $30 per hour. The technical staff are required to work 8 hours per day at the rate of $25 per hour. The janitorial staff are required to work 7 hours per day at the rate of $10 per hour. In addition, the following rules apply for the hours of employment: The office building is closed between the hours of midnight and 6:00AM. Hence, an employees work day must start on or after 6:00AM and must end strictly before midnight. If an employee works fewer hours than the number of hours required for her category, she will get paid at an hourly rate that is 0.8 times the regular rate. For example, if a member of the technical staff works only 6 hours on a given day, she will get paid $20 per hour (not $25). Hence, her salary for that day is $120. If an employee works overtime (that is more than the number of hours required for her category), she will get paid at an hourly rate that is 1.25 times the regular rate for the extra hours. For example, if a member of the janitorial staff works 9 hours and 20 minutes on a given day, she will get paid $70 for the 7 hours she is required to work. For the two hours and 20 minutes of overtime, she will get paid $12.50 per hour, which amounts to $29.17. Hence, her salary for that day is $99.17. You are asked to write a program that first asks the user for their category of employment (M for managerial, T for technical, and J for janitorial), the time at which her work day started, and the time at which her work day ended. The start and end times should be entered in military format. Recall that time in military format is based on a 24 hour clock. Some examples: 8:45AM is written as 0845, midnight is written as 0000, 12:45AM is written as 0045, noon is written as 1200, and 8:45PM is written as 2045. Your program should check for the validity of input. In particular, if the user enters a character other than M, T, or J for the employee type, your program should print an appropriate error message and quit. Also, if the user enters an invalid military time for either the start or end time (keep in mind that both the hour and minute values should be valid), then too the program should print an appropriate error message and quit. If the start and/or end time occurs in the period midnight to 5:59AM, print an appropriate message and quit. Finally, if the start time occurs after the end time, your program should print an appropriate message and quit. Once the program has read all input and determined its validity, it should print out a daily salary report with the following information: (1) Type of the employee, (2) the start time in AM/PM format, (3) the end time in AM/PM format, (4) the total hours worked, (5) the rate at which the employee is paid, including overtime (if any), and (6) the total salary for that day. (See sample runs for some examples.) You are required to implement the following functions to carry out the above tasks. 1. (4 points) Implement a function called valid mil time with a single parameter called mtime, which is a string. This function returns the boolean value True if mtime is a valid military time and False otherwise. To be valid, mtime should be exactly 4 characters long. Furthermore, the hour value and the minute value should be valid as well. 2. (4 points) Implement a function called minutes elapsed with two parameters, mtstart and mtend, both of which are string representing military times. You may assume that 5 both are valid military times and also that mtend occurs on or after mtstart. This function returns the number of minutes that have elapsed between mtstart and mtend. For example, minutes elapsed("0830", "1745") returns 555, and minutes elapsed("1135", "1710") returns 335. 3. (6 points) Implement a function called ampm with a single parameter called mtime, which is a string representing a military time. This function returns a string representing the AM/PM time corresponding to mtime. You may assume that mtime is a valid military time. For example, ampm("0845") should return the string "8:45AM", ampm("0000") should return the string "12:00AM", and ampm("2359") should return the string "11:59PM". 4. (10 points) Implement a function called daily salary report with three parameters: emp type (a single character representing the type of employee), mtstart (the start time) and mtend (the end time). This function should print a daily salary report as described above (also see sample runs). Note: Call the functions ampm and minutes elapsed when implementing this function. Do not repeat code unnecessarily. 5. (8 points) Implement a function called salary calc without any parameters. (This is the function I will call when testing your program in the Python shell.) This function should use the input function to read in three values from the user (see sample runs): the type of employee, the start time in military format, and the end time in military format. This function must check for validity of input. This means that the employee type should be valid (M, T, or J), the start and end times should be valid (use valid mil time to check validity of time), the start time should occur on or after 6:00AM, the end time should occur before midnight, and the end time should occur after start time. If any of these validity requirements are violated, this function prints an appropriate message and quits. Otherwise, once you have ensured that all the input is valid, call daily salary report to print out the daily salary report.

image text in transcribed

image text in transcribed

Thanks

Some sample runs of the program are given below. >salary-calc) DAILY SALARY CALCULATOR Enter the type of employee: M Enter the start time: 0830 Enter the end time: 1745 Daily salary report Type of employee: Managerial Start time: 8:30AM End time: 5:45PM Total hours worked: 9 hours and 15 minutes Pay rate (s): $24.00/hr for 9 hours and 15 minutes Total Salary: $222.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Students also viewed these Databases questions

Question

Q.No.1 Explain Large scale map ? Q.No.2 Explain small scale map ?

Answered: 1 week ago