Question: Write an algorithm and a Python program to process a file that contains expenses. The input file is names Program 3 - Expenses.txt .

Write an algorithm and a Python program to process a file that contains expenses. The input file is
names "Program 3- Expenses.txt". Each expense has a dollar amount and an expense category.
There are 5 expenses categories:
Food
Housing
Transportation
Entertainment
Misc
Each line of the input file has the format as follows. The dollar amount is separated from the
category by a space.
100.00 Food
92.46 Housing
12.12 Transportation
The program should read each line in the file and split the amount from the category and sum all the
expenses for each of the 5 categories. An output file needs to be created that will write the category
and the total for all the expenses in that category as well as a grand total as displayed below. Each
value should be rounded to 2 decimal places. The output file should be named "Expenses-
Output.txt".
Food Total: 556.88
Housing Total: 436.46
Transportation Total: 232.42
Entertainment Total: 1,750.35
Misc Total: 259.14
Grand Total: 3,235.25
The only output on the screen should be the number of expenses; grand total of expenses and a
message indicating the output file was created as shown below.
There were 24 expenses that totaled: 3,235.25
Output file: Expenses-Output.txt has been created.
please use basic python
Write an algorithm and a Python program to

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Accounting Questions!