Your program should expect to read a file similar to the one shown below (and also available on D2L).
Your program should:
- Prompt for the name of the file to process and issue an error message and terminate if that file cant be opened
- Verify that each line has the correct number of items and terminate if it does not
- Verify that the dollar amount is a valid floating-point number and terminate if it is not
- Keep a list with the categories that are encountered (they may be different than below) and another list with the cumulative dollar amount for each category. These are two lists but the elements in one relate to the elements in the other (by position)
- Close the file when all the data has been processed
- Display the categories and the total for each one
Sample input file:
Bob;Dinner;10.00;January 1, 2015 Tom;Dinner;14.00;January 2, 2015 Anne;Lodging;125.00;January 3, 2015 Jerry;Lodging;125.00;January 4, 2015
Output from running with the above correct file should be:
Enter the name of the file to display: input.txt
Totals:
Dinner: $ 24.00 Lodging: $ 250.00
The wordings of messages given when the program must terminate because of an error are your choice but must be clear, correct English.
Submit your program to the designated D2L drop box. Your program should be named PA3.py. For programming assignments, early submissions gain a bonus percent: 1 day early 10%; 3 or more days early 20%.
Reviews
There are no reviews yet.