DESCRIPTION: Write a program that asks the user to enter the amount that he or s
ID: 3621163 • Letter: D
Question
DESCRIPTION: 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.
Following is a copy of the screen results that might appear after running your program, depending on the data entered. The input entered by the user appears in bold.
Enter the amount you have budget for a month: 700
Enter the bill type or the word done to quit: Rent
Enter bill amount: 550
Enter the bill type or the word done to quit: Food
Enter bill amount: 100
Enter the bill type or the word done to quit: Gas
Enter bill amount: 35
Enter the bill type or the word done to quit: done
Sum of monthly bill is 685
You are 15 under budget
Explanation / Answer
Ill assume you know the basic openings. Below is the main function. public static void main(string args[]) { Scanner scan = new Scanner(); double budget=0, num=0, total=0; System.out.println("How much have you budgeted for the month? :"); budget=scan.nextDouble(); System.out.println("enter each expense, then type -999 to quit: "); while(num!=-999) { total+=num; num=scan.nextDouble(); } if(totalRelated Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.