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 Expenses.txt Each expense has a dollar amount and an expense category.
There are 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.
Food
Housing
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 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 decimal places. The output file should be named "Expenses
Output.txt
Food Total:
Housing Total:
Transportation Total:
Entertainment Total:
Misc Total:
Grand Total:
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 expenses that totaled:
Output file: ExpensesOutput.txt has been created.
please use basic python
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
