Question
Question: Budget Analysis Write a program that asks the user to enter the amount that he or she has budgeted for a month. A loop
Question:
Budget Analysis
Write a program that asks the user to enter the amount that he or she has budgeted for a month. A loop should then prompt the user to enter each of his or her expenses for the month and keep a running total. When the loop finishes, the program should display the amount that the user is over or under budget.
In each repetition through the loop, the program should prompt the user for name of the expense and the amount of the expense. The program should print the name of the expense and the amount of the expense. keep a running total of all expenses entered. When the loop finishes, the program should display the total amount that the user entered and indicate if the total amount is over or under budget.
The program should print the amount of the expense for each item next to item name
The program should display the amount budgeted
The program should display the amount actually spent
The program should display the amount that the user is over or under budge
indicate if the total amount is over or under budget.
My Answer So Far:
Budgetforthemonth = float( input ( "Enter you budget for the month: " ) )
AdditionalExpenses = "y"
TotalExpenses = 0
while AdditionalExpenses == "y":
ExpenseName = input ( "Enter the name of an expense: ")
Expenses = float( input( "Enter the expense: "))
TotalExpenses = TotalExpenses + Expenses
AdditionalExpenses = input ( "Anymore additional expenses?: Type y "+ \
"for yes, any key for no: " )
if TotalExpenses > Budgetforthemonth:
print( "You have over drawn your budget of $",Budgetforthemonth, "by $", TotalExpenses -\
Budgetforthemonth,".","Total Spent:",TotalExpenses)
elif Budgetforthemonth > TotalExpenses:
print( "You are under your budget of $", Budgetforthemonth,"by $",Budgetforthemonth - \
TotalExpenses,".","Total Spent:",TotalExpenses )
else:
print( "You have perfectly used up your budget of $", Budgetforthemonth,"!","Total Spent:",TotalExpenses )
I would like to know how to list my expenses in a list format which I dont know how to do "The program should print the amount of the expense for each item next to item name" <- that one
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