In: Computer Science
In python, write a program that asked the user to enter the monthly costs for the following expenses incurred from operating his automobile: loan payment, insurance, gas, oil, tires, and maintenance. The program should display total monthly cost and annual cost. Also, should contain main and calcExpenses functions, calcExpenses should only calculate the expenses and everything else should happen in the main function.
Code -
def calcExpenses():
#ask user loan payment cost
loanPayment = float(input("Enter monthly cost for loan payment:
"))
#ask user insurance cost
insurance = float(input("Enter monthly cost for insurance:
"))
#ask user gas cost
gas = float(input("Enter monthly cost for gas: "))
#ask user oil cost
oil = float(input("Enter monthly cost for oil: "))
#ask user tires cost
tires = float(input("Enter monthly cost for tires: "))
#ask user maintenance cost
maintenance = float(input("Enter monthly cost for maintenance:
"))
#calculate the total
total = loanPayment+insurance+gas+oil+tires+maintenance;
#return total
return total
if __name__ == '__main__':
#call function calcExpenses and get the total monthly
Expenses
monthlyExpenses = calcExpenses()
#print the total Monthly Expenses
print("Total Monthly cost "+str(monthlyExpenses))
#print the Annual cost by multiplying monthlyExpenses by 12
print("Total Annual cost "+str(monthlyExpenses*12))
Screenshots -
pls do give a like , thank you