question archive File Name: FirstLastHW6

File Name: FirstLastHW6

Subject:Computer SciencePrice:0 Bought3

File Name: FirstLastHW6.py

Due: see syllabus

Directions:

e Turn in all .py files on BlackBoard.

e Make sure you save the file before turning it in.

e You do not need to turn in the text file.

e Two sample text files have been provided for you to test with. Please keep in mind that you should modify

these files and test with other scenarios. Remember that | will be doing this when | test.

Requirements:

e Create one file called FirstLastHW6.py

e Inside main(), write code that will do the following:

o Calculate a running total of all numbers in both files as follows:

* The numbers in add.txt should be added to the total.

® The numbers in subtract.txt should be subtracted from the total.

o Your program should take this final total and create a new file called total.txt. Write one line into this

file as follows:

*® The text: Running Total, followed by a colon, followed by a space, followed by the running total

that you calculated.

* If the file already exists, you should overwrite it.

o Your program, when finished, should print the following: “The running total is (the value) and it has been stored in the file total.txt”

e It is possible that one or both files may be missing. If a file is missing, do not include it in the running total.

e It is possible that one or both files may contain no data (empty file). If there are no numbers in the file, there is nothing for you to include from that file in the running total.

e Files will not contain bad data. In other words, if there is data in a file, it will contain one number on each line.

e You may assume that all data consists of integers.

pur-new-sol

Purchase A New Answer

Custom new solution created by our subject matter experts

GET A QUOTE