Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON CODE First Code: Write a program that uses a text file to store the days and hours that a user worked in a week.

PYTHON CODE

First Code:

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

Second Code:

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

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

Recommended Textbook for

Database Systems For Advanced Applications 15th International Conference Dasfaa 2010 International Workshops Gdm Benchmarx Mcis Snsmw Diew Udm Tsukuba Japan April 2010 Revised Selected Papers Lncs 6193

Authors: Masatoshi Yoshikawa ,Xiaofeng Meng ,Takayuki Yumoto ,Qiang Ma ,Lifeng Sun ,Chiemi Watanabe

2010th Edition

3642145884, 978-3642145889

More Books

Students also viewed these Databases questions

Question

What is management growth? What are its factors

Answered: 1 week ago

Question

Additional Factors Affecting Group Communication?

Answered: 1 week ago