Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use methods like the code below to write your codes, thanks. I want to se

ID: 3914420 • Letter: P

Question

Please use methods like the code below to write your codes, thanks. I want to see how do you calculate sum in a method with the values from other methods.

This interactive program focuses on if/else statements, scanner, and returning values. Turn in 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 course web 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 This program asks for your monthly income and expenses,then tells you your net monthly income. How manycategories of income? 3 Next income amount? $1000 Next income amount? $250.25 Next income amount? $ categories, then reads in that many income amounts Next, the program asks whether the user would like (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 to enter monthly or daily expenses. Enter 1) monthly or 2) daily expenses? 1 How many categories of expense? 4 Next expense amount? $850 Next expense amount? $49.95 Next expense amount? $75 Next expense amount? $I20.67 read Total income $1425.75 ($47.53/day) Total expenses$1095.62 ($36.52/day) 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 30 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 much. If income and expenses were exactly equal, the user is considered to have earned $O more than they spent (as opposed You earned $330.13 more than you spent this month. You're a big saver your custom message> 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 given month and by how Enter 1) monthly or 2) daily expenses? 2 How many categories of expense? 1 Next expense amount? $45. 33 to spending S0 more than they earned) Total income = $1000.25 ($33.34/day) Total expenses$1359.90 $45.33/day) Finally, the program should print out which category the user falls into based on their net income for the You spent $359.65 more than you earned this month.month (rounded to two decimal places). The four You're a big spender categories are defined as follows your custom message>> +S250.00 or more: "big saver" -$249.99 to -S0.01 spender" S0.00 to +S249.99:"saver" $250.00 or less 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. 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 2 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 should 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

Explanation / Answer


Given below is the code for the question.
To indent code in eclipse , select code by pressing ctrl+a and then indent using ctrl+i
Please do rate the answer if it was helpful. Thank you


import java.util.Scanner;

public class Budgeter {
static int MONTH_DAYS = 30;
static Scanner console = new Scanner(System.in);

public static void main(String[] args) {
double monthlyIncome = 0, monthlyExpense = 0;

programIntro();
monthlyIncome = getIncomes();
monthlyExpense = getExpense();
showOutput(monthlyIncome, monthlyExpense);
}

public static void programIntro(){
System.out.println("This program asks for your monthly income and");
System.out.println("expenses, then tells you your net monthly income. ");
}

public static double getIncomes(){
int numIncomes;
double income, total = 0;
System.out.print("How many categories of income? ");
numIncomes = console.nextInt();
for(int i = 1; i <= numIncomes; i++)
{
System.out.print(" Next income amount? $");
income = console.nextDouble();
total += income;
}
return total;
}

public static double getExpense(){
int numExpenses;
int expenseType;
double expense, total = 0;
System.out.println();
System.out.print("Enter 1) monthly or 2) daily expenses? ");
expenseType = console.nextInt();

System.out.print("How many categories of expense? ");
numExpenses = console.nextInt();

for(int i = 1; i <= numExpenses; i++)
{
System.out.print(" Next expense amount? $");
expense = console.nextDouble();
total += expense;
}

if(expenseType == 2) //monthly type
total *= MONTH_DAYS;
return total;
}


public static void showOutput(double monthlyIncome, double monthlyExpense){
double savings = monthlyIncome - monthlyExpense;
double dailyIncome = monthlyIncome / MONTH_DAYS;
double dailyExpense = monthlyExpense/ MONTH_DAYS;

System.out.println();
System.out.printf("Total income = $%.2f ($%.2f/day) ", monthlyIncome, dailyIncome);
System.out.printf("Total expenses = $%.2f ($%.2f/day) ", monthlyExpense, dailyExpense);
displayMessage(savings);
}

public static void displayMessage(double savings){
System.out.println();
if(savings >= 0)
System.out.printf("You earned $%.2f more than you spent this month. ", savings);
else
System.out.printf("You spent $%.2f more than you earned this month. ", -savings);

if(savings >= 250){
System.out.println("You are a big saver.");
System.out.println("Keep continuing the same !");
}
else if(savings >= 0){
System.out.println("You are a saver.");
System.out.println("With a little effort, you can save more!");
}
else if(savings >= -249.99){
System.out.println("You are a spender.");
System.out.println("You must plan to spend less and start saving!");
}
else{
System.out.println("You are a big spender.");
System.out.println("This is really bad! Spend less.");
}
}

}


output
=====
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? 250.25
Next income amount? 175.50
Enter 1) monthly or 2) daily expenses? 1
How many categories of expense? 4
Next expense amount? 850
Next expense amount? 49.95
Next expense amount? 75
Next expense amount? 120.67
Total income = $1425.75 ($47.53/day)
Total expenses = $1095.62 ($36.52/day)
You earned $330.13 more than you spent this month.
You are a big saver.
Keep continuing the same !