Answered step by step
Verified Expert Solution
Question
1 Approved Answer
PYTHON CODE: write the second program Write a program that uses a text file to store the days and hours that a user worked in
PYTHON CODE: write the second program
Write a program that uses a text file to store the days and hours that a user worked in a week. The program should begin by prompting for the number of days worked in the week. It should continue with a loop for input of the days and hours and for writing these to the file, each on its own line.
Sample Output (inputs shown in boldface)
How many days did you work this week? 5
Enter day of week Monday
How many hours did you work on Monday? 10
Enter day of week Tuesday
How many hours did you work on Tuesday? 8
Enter day of week Wednesday
How many hours did you work on Wednesday? 12
Enter day of week Friday
How many hours did you work on Friday? 12
Enter day of week Saturday
How many hours did you work on Saturday? 8
File was created
Now write another program that reads the text file created in the program above and calculates the user's weekly pay. The program should begin by prompting the user for the regular hourly pay rate. The program should then loop through the file and report the days and hours worked. The program should finish by calling a custom void function named calc_pay that calculates and prints the weekly pay, including overtime, if applicable. By law, weekly hours in excess of 40 should be paid at 1.5 times the regular hourly rate. The calc_pay function takes two arguments, total hours and hourly pay rate, and it must be imported from a separate module file. Note that three outputs are required for the pay.
Sample Output 1
Enter your hourly pay rate 25.00
Here are your hours this week
Monday hours : 10.0
Tuesday hours : 8.0
Wednesday hours : 12.0
Friday hours : 12.0
Saturday hours : 8.0
You worked 50.0 hours this week
You worked 10.0 hours overtime
Your hourly pay rate is $25.00
Regular pay : $1,000.00
Overtime pay : $375.00
Total pay : $1,375.00
Sample Output 1 (for a different work week)
Enter your hourly pay rate 25.00
Here are your hours this week
Monday hours : 10.0
Wednesday hours : 12.0
Friday hours : 12.0
You worked 34.0 hours this week
Your hourly pay rate is $25.00
Regular pay : $850.00
Overtime pay : $0.00
Total pay : $850.00
this is the First code needed to do the second
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started