Timesheet data is easy to represent in a file, where it can be used to generate a report and help the worker get paid! Given an example set of data where each row represents a day of the week and each entry on the row represents a block of time worked, like this: 0h 1.5h 3.25h 3.0h 6.0h 1.0h 5.5h 2.25h 0.75h 2.25h 3.0h 3.0h 5.75h 2.25h 0h A report could be produced by a program like this: --------------------------------------- 0.00h | 0.00h 5.25h | 1.50h 3.25h 0.50h 10.00h | 3.00h 6.00h 1.00h 8.50h | 5.50h 2.25h 0.75h 8.25h | 2.25h 3.00h 3.00h 8.00h | 5.75h 2.25h 0.00h | 0.00h --------------------------------------- Weekly Total: 40.00h Notice how in the output file all the numbers are nicely formatted as right-aligned. Hint: you will probably need to use splitting, string slicing, converting data types, and string formatting. For your assignment, create a program that uses a data file that you have created, parses the data in that file to create a calculation per row and a running total, then writes the report to an output file. Your program should prompt a user to input a file containing the data, then prompt the user to enter a file name for outputting the report and the total, formatted similarly to the example above. Here is an example interaction for our timesheet example: Enter timesheet file name: mcbride_timesheet_20210606.txt Enter name for report file: mcbride_timereport_20210606.txt Done writing totals to mcbride_timereport_20210606.txt
Timesheet data is easy to represent in a file, where it can be used to generate a report and help the worker get paid! Given an example set of data where each row represents a day of the week and each entry on the row represents a block of time worked, like this:
0h
1.5h 3.25h
3.0h 6.0h 1.0h
5.5h 2.25h 0.75h
2.25h 3.0h 3.0h
5.75h 2.25h
0h
A report could be produced by a program like this:
---------------------------------------
0.00h | 0.00h
5.25h | 1.50h 3.25h 0.50h
10.00h | 3.00h 6.00h 1.00h
8.50h | 5.50h 2.25h 0.75h
8.25h | 2.25h 3.00h 3.00h
8.00h | 5.75h 2.25h
0.00h | 0.00h
---------------------------------------
Weekly Total: 40.00h
Notice how in the output file all the numbers are nicely formatted as right-aligned. Hint: you will probably need to use splitting, string slicing, converting data types, and string formatting.
For your assignment, create a program that uses a data file that you have created, parses the data in that file to create a calculation per row and a running total, then writes the report to an output file. Your program should prompt a user to input a file containing the data, then prompt the user to enter a file name for outputting the report and the total, formatted similarly to the example above. Here is an example interaction for our timesheet example:
Enter timesheet file name: mcbride_timesheet_20210606.txt
Enter name for report file: mcbride_timereport_20210606.txt
Done writing totals to mcbride_timereport_20210606.txt
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 7 images