Reference no: EM132265491
Budgeter.java
This interactive program focuses on if/else statements, Scanner, and returning values. a file named Budgeter.java. To use a Scanner for console input, you must import java.util.*; in your code.
This program prompts a person for income and expense amounts, then calculates their net monthly income. Below are two example logs of execution from the program. This program's behavior is dependent on the user input (user input is bold and underlined below to make it stand out). Your output should match our examples exactly when given the same input. (Be mindful of spacing, such as after input prompts and between output sections.) Look at the other example logs on the Canvas site to get more examples of the program's behavior.
The program begins with an introductory message that briefly explains the program. The program prompts the user for the number of income categories, then reads in that many income amounts. Next, the program asks whether the user would like to enter monthly or daily expenses. (The user enters 1 for monthly and 2 for daily.) The program will then read in a number of expense categories and an amount for each category, similar to how income was read.
The program should then print out the total amount of income and expenses for the month, as well as the average amount of each per day. You may assume a month has exactly 31 days, though your program should be able to be easily modified to change this assumption (see below).
After printing the total income and expenses, the program should print out whether the user spent or earned more money for the given month and by how much. If income and expenses were exactly equal, the user is considered to have earned $0 more than they spent (as opposed to spending $0 more than they earned).
Finally, the program should print out which category the user falls into based on their net income for the month (rounded to two decimal places). The user's net income is the result of subtracting their expenses from their income. The four categories are defined as follows:
More than +$250: "big saver"
More than $0 but not more than +$250: "saver"
More than -$250 but not more than $0: "spender"
-$250 or less: "big spender"
After printing the user's category, print a custom message of your choice about their spending habits. This message should be different for each range shown above. It should be at least 1 line of any non-offensive text you like.
Sample run. Things in bold and underlined are user input:
This program asks for your monthly income and
expenses, then tells you your net monthly income.
How many categories of income? 3
Next income amount? $1000
Next income amount? $205.25
Next income amount? $175.50
Enter 1) monthly or 2) daily expenses? 1
How many monthly categories of expense? 4
Next expense amount? $850
Next expense amount? $49.95
Next expense amount? $75
Next expense amount? $120.67
Total income = $1380.75 ($44.54/day)
Total expenses = $1095.62 ($35.34/day)
You earned $285.13 more than you spent this month.
You're a big saver.
<<your custom message here>
Another sample run. Things in bold and underlined are user input:
This program asks for your monthly income and
expenses, then tells you your net monthly income.
How many categories of income? 2
Next income amount? $800
Next income amount? $200.25
Enter 1) monthly or 2) daily expenses? 2
How many daily categories of expense? 1
Next expense amount? $45.33
Total income = $1000.25 ($32.27/day)
Total expenses = $1405.23 ($45.33/day)
You spent $404.98 more than you earned this month.
You're a big spender.
<<your custom message here>
This program processes user input using a Scanner. All monetary inputs will be real numbers; all other input will be integers. You may assume the user always enters valid input. When prompted for a value, the user will enter a value of the correct type. The user will enter a number of income and expense categories ≥ 1 and will only ever enter 1 or 2 when asked how to enter expenses. The amount for each category of income and expense will be a non-negative number.
You are required to define a class constant for the number of days in a month. You should refer to this constant throughout your program so that the value can be changed and your program will continue to function correctly.