Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The program worked before but an unexperienced programmer tried and enhance it and ended up ruining it ! ! ! Before attempting to fix it
The program worked before but an unexperienced programmer tried and enhance it and ended up ruining it Before attempting to fix it you need to know what the program was meant to do See the program description below Description: "The program should allow the user to enter their monthly expenses and should then display the total monthly and yearly expenses based on what was entered". An example of how the program should work is shown below Enter the monthly rent or mortgage amount:
Enter the monthly amount spent on car insurance if applicable: Enter the monthly amount spent on gas or transportation:
Enter amount spent on electricity:
Enter water bill amount:
Enter the monthly amount spent on Groceries:
Are there more expenses you would like to add? :
Enter the monthly amount spent Extra expenses:
Total monthly expense: $
Total annual expense: $
Important points to remember:
Notice from the example shown above, the program allows the user to enter addtional expenses if they have any. This is important to remember
Pay attention to the way the totals are displayed in the end, notice there is no space between the dollar sign $ and the total.
below are the program files, notice it uses functions. You can and should fix the functions if needed but you can NOT delete the functions
# The showExpenses function accepts mortgagerent car insurance if applicable
# gas or transportation, electric, water, and groceries # arguments and displays the equivalent total expense
# information.
def showExpenseshouse gas, insure, elec, water, grocery, extra
totalMonth housing insurance gas elec water grocery
totalYear totalMonth
return totalMonth, totalYear
# function displays total monthly and yearly expenses
def display totalMonth totalYear
# Print monthly and annual information.
print Total monthly expense: totalMonth:
print f "Total annual expense:" StotalYear:f
import
exFunction.py as
# main module
def main
# Get the monthly payment for housing.
housing floatinputEnter the monthly rent or mortgage
amount:
# Get the amount of insurance.
ins inputEnter the monthly amount spent on car
insuranceif applicable:
# Get the amount of gas.
gas inputEnter the monthly amount spent on gas or
transportation:
# Get the amount of electiricy.
electricy inputEnter amount spent on electriciy:
# Get the amount for water.
water floatinputEnter water bill amount:
# Get the amount for Groceries.
groceries inputEnter the monthly amount spent on Groceries:# ask if there are other expenses they would like to include more int inputAre there more expenses you wouild like to add? yn: if more y # get monthly amount spent on these additional expenses additional floatinputEnter the monthly amount spentExtra expenses: else:additional # calculate expensesfn.showExpenseshouse insurance, gas, electricy, water, groceries# display results monthly and annual total expensesdisplaymonExp yearExHints:
string can be used to format output, I reference that in the videos I posted.
the program has pseudocode, comments, that should give you some guidance as to what code that appears below these comments is to do
Download the zipped folder below, it contains the two program files you need fix. When fixed, run the program and make sure that delivers results similar to what is shown above.
Create flowchart for program refer to posted Powerpoint "Flowcharts"
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started