Question
Write a program that allows users to input their monthly expenses and determine if they stayed within their personal budget for that time period. First,
Write a program that allows users to input their monthly expenses and determine if they stayed within their personal budget for that time period.
First, ask the user to enter the number of months they would like to input and their overall budget for that time period. Validate the user's input to make sure they enter positive values greater than 0.
For each month, prompt the user for their weekly expenses. You can assume their are 4 weeks in each month. Ensure that the values entered are positive - if they aren't you will need to re-prompt them. Hint: you may need to use nested loops here! A "while" loop can be placed inside of a "for" loop, if necessary.
Once your program has collected all the weekly expenses for a month, it should display the user's average weekly expense and move onto the next month. When all months have been collected, the program should compute the overall average weekly average for the entire time period. It should also report if the user stayed within budget or if they went over budget for the time period. If the user went over budget, also report by how much.
Here is a sample output of the program:
How many months would you like to analyze? -5 Invalid number of months, try again. How many months would you like to analyze? 2 What is your budget for this time period? -10 Invalid budget, try again. What is your budget for this time period? 150.50 Here we go! **** Month #1 **** Week #1 Expenses: 40.44 Week #2 Expenses: 26 Week #3 Expenses: 40 Week #4 Expenses: 10.33 Month #1 Average Weekly Expense: 29.19 **** Month #2 **** Week #1 Expenses: 25.10 Week #2 Expenses: 40.50 Week #3 Expenses: 66.13 Week #4 Expenses: 3 Month #2 Average Weekly Expense: 33.68 Average weekly expense for ALL months: 31.44 Total expenses across 2 months: 251.50 Oh no! You went over budget by 101.00!
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