225k views
5 votes
The logic of a program That allows the user to enter a value for hours worked in a day. The program calculates the hours worked in a five day week and the hours worked in a 252 day work year. The program outputs all the results

1 Answer

2 votes

Answer: here's an example of a program logic in Python that allows the user to enter the number of hours worked in a day, calculates the hours worked in a five-day week, and the hours worked in a 252-day work year. The program will then output all the results:

# Prompt the user to enter the number of hours worked in a day

hours_per_day = float(input("Enter the number of hours worked in a day: "))

# Calculate hours worked in a five-day week

hours_per_week = hours_per_day * 5

# Calculate hours worked in a 252-day work year

hours_per_year = hours_per_day * 252

# Output the results

print("Hours worked in a five-day week:", hours_per_week)

print("Hours worked in a 252-day work year:", hours_per_year)

In this program, the user is prompted to enter the number of hours worked in a day using the input() function. The value is stored in the hours_per_day variable.

Then, the program calculates the hours worked in a five-day week by multiplying hours_per_day by 5 and stores the result in the hours_per_week variable.

Similarly, the program calculates the hours worked in a 252-day work year by multiplying hours_per_day by 252 and stores the result in the hours_per_year variable.

Finally, the program uses the print() function to output the results to the user.

You can run this program in a Python environment to test it with different values for the number of hours worked in a day.

Step-by-step explanation:

User Swetabh Suman
by
8.3k points

No related questions found