Question

In: Computer Science

A company needs calculating the total working time of employees in a team. You are going...

A company needs calculating the total working time of employees in a team. You are going to help to write a program that totals the working time in hours and minutes.   You should name your program as workingTime.py.
Your program should first ask the user how many employees there are on the team. You may assume the value entered will not be negative, but it could be zero. Your program will now be controlled by a loop that asks for, and adds, the hours and minutes for each employee. Of course the minutes will frequently add up to more than an hour, but you should not report a total time such as 24 hours 77 minutes for example (or worse, 18 hours 377 minutes). Instead you should report the total time as 25 hours 17 minutes . On the other hand, if the total number of hours is 24 or greater you should not report the time in days, hours and minutes.   Hours and minutes are all that are to be reported.

While you may assume that all of the hours and minutes entered by the user will be nonnegative, a time may be entered with minutes that exceed 60. Your program should be able to handle this and still report the total correctly. For example, 5 hours, 65 minutes and 3 hours, 88 minutes should add up to 10 hours, 33 minutes. Consequently for a given team we should see output such as:

Total time: 29 hours 18 minutes

Note:     1. The number 29 and 18 is calculated based on the user’s input.
2. If you already know about conditionals, you may not use them in this program.

In part II, the company needs to calculate the total working time for employees from all teams in days, hours, and minutes. Users of the program report that they do not like having to start the program over and over to process multiple teams, so we are going to fix that complaint.   

Add code to first ask how many teams are to be processed (you may assume the value entered is non-negative). Use this number to determine how many times the program will go through one loop (known as an outer loop) that contains within it the code from part 1. Since the loop from the code of part 1 will now lie within the loop you are developing for this part of the assignment, it is known as the inner loop. At the end of each pass of the outer loop your program should identify the team being processed as Team1, Team2, etc. and then report the total time of that Team. Thus we may see output such as:

Team1 Total time: 29 hours 18 minutes
Team2 Total time: 27 hours 49 minutes
Team3 Total time: 15 hours 1 minutes

Finally, add code to output the total time of all of the teams entered. Thus, the last line of output may be: Total time of all teams: 3 days 0 hours 8 minutes Note that the total time for all teams should display the number of days, hours, and minutes.

If you already know about conditionals, you may not use them in this program.

Solutions

Expert Solution

If you have any doubts, please give me comment...

teams_work_hours = []

no_teams = int(input("Enter How many teams:"))

for team in range(1, no_teams+1):

    totalMins = 0

    no_emps = int(input("Enter how many employees there are on the team-"+str(team)+": "))

    for emp in range(1, no_emps+1):

        hours = int(input("Enter how many hours worked for employee "+str(emp)+": "))

        mins = int(input("Enter how many minutes worked for employee "+str(emp)+": "))

        totalMins += hours*60 + mins

    teams_work_hours.append(totalMins)

teamNo = 1

totalTime = 0

for w_hours in teams_work_hours:

    print("Team"+str(teamNo)+" Total time:{0} hours {1} minutes".format((w_hours//60), (w_hours%60)))

    totalTime += w_hours

    teamNo += 1

print("Total time of all teams:{0} days {1} hours {2} minutes".format((totalTime//1440), ((totalTime%1440)//60),((totalTime%1440)%60)))


Related Solutions

You are working with a team designing capacitors for specialized purposes. One client needs a capacitor...
You are working with a team designing capacitors for specialized purposes. One client needs a capacitor shaped like a sphere that can store the most energy for its size. You are to begin the design process by performing calculations for a simple spherical capacitor consisting of two thin concentric spherical shells separated by a dielectric. You decide to calculate the maximum energy that can be stored in terms of the radius of the outer shell and the maximum electric field...
Assuming you are working in a team for a company, do you think there are any...
Assuming you are working in a team for a company, do you think there are any ethical issue if you know that one of the team members is actually interviewing with other company. The team member does not want to inform the team of his or her intention to leave until he or she gets an offer. Do you think it is ethical that you also decide to act ignorant about it and not telling your team lead or manager...
Danisco Manufacturing consists of 85 full-time employees and 25 part-time employeess. The full-time employees' working hours...
Danisco Manufacturing consists of 85 full-time employees and 25 part-time employeess. The full-time employees' working hours are 8-hour per day, 5 days per weel in a year. The total overtime worked by the full-time employee is 2900 hours, and the total hours worked by the part-time employee is 1500 hours in year 2016. 18 injuries were recorded at the workplace in year 2016. Determine the OSHA incidence rate based on injuries for year 2016.
The last time that information on employees working at this bank was collected, the number of...
The last time that information on employees working at this bank was collected, the number of months of previous work experience was distributed such that 15% of employees had a less than 2 years of experience, 25% had between 2 and 5 years of experience, 20% had more than 5 years and up to 10 years of previous work experience, and 40% had more than 10 years of experience. Verify at a 0.05 level of significance if the current data...
The last time that information on employees working at this bank was collected, the number of...
The last time that information on employees working at this bank was collected, the number of months of previous work experience was distributed such that 15% of employees had a less than 2 years of experience, 25% had between 2 and 5 years of experience, 20% had more than 5 years and up to 10 years of previous work experience, and 40% had more than 10 years of experience. Verify at a 0.05 level of significance if the current data...
Imagine you are working on a team and one of your team members is writing a...
Imagine you are working on a team and one of your team members is writing a library of C functions to work with strings. They decide to name their library mystringfunctions, and have two files: a source file mystringfunctions.c and a header file mystringfunctions.h. In this problem, you will write automated tests known as unit tests. This program has been partially written for you in testmystringfunctions.c. Write the body of functions that are marked with a comment that begins with...
Calculating a Loan With the PMT Function in Excel Everyone needs to borrow money some time....
Calculating a Loan With the PMT Function in Excel Everyone needs to borrow money some time. Every time you use your credit card you are taking out a loan. The key question for most people is “What will my monthly payment be?” Fortunately, Excel has a special function just for this calculation, called PMT. The basic syntax for PMT is as follows: =PMT(rate, nper, pv) Let’s break down the ARGUMENTS you have to input: The rate input is the amount...
Case Study: Assume that the company, where you are working as a team in Financial Department,...
Case Study: Assume that the company, where you are working as a team in Financial Department, is considering a potential project with a new product that is expected to sell for an average price of $22 per unit and the company expects it can sell 650 000 unit per year at this price for a period of 4 years. Launching this project will require purchase of a $3 500 000 equipment that has residual value in four years of $500...
You and your management team are working to develop the strategic direction of your company for...
You and your management team are working to develop the strategic direction of your company for the next three years. One issue you are discussing is how to finance the projected increases in operating assets. Your options are to rely more heavily on operating creditors, borrow the funds, or to sell additional stock in your company. Discuss the pros and cons of each source of financing.
Case Study: Assume that the company, where you are working as a team in Financial Department,...
Case Study: Assume that the company, where you are working as a team in Financial Department, is considering a potential project with a new product that is expected to sell for an average price of $22 per unit and the company expects it can sell 650 000 unit per year at this price for a period of 4 years. Launching this project will require purchase of a $3 500 000 equipment that has residual value in four years of $500...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT