1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
alukav5142 [94]
2 years ago
11

Write a program that asks the user to enter the amount s/he has budgeted for a month. The amount should be between 1000 and 2000

(do an input validation). A loop should then prompt the user to enter each of the expenses (show at least 3 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 or exactly on budget. # Hints # Declare variables to store the budget amount, amount spent, difference, and total. # Initialize for while loop # Get the budgeted amount from the user and do input validation # Get the total amount spent from the user (while statement starts, make sure to enter exit criteria) # Determine whether the user is over or under budget, and display the result (if elif else) # print what was the budgeted amount # print what was the amount spent
Computers and Technology
1 answer:
Elena-2011 [213]2 years ago
5 0

Answer:

The program to this question can be given as:

Program:

  //import package for user input.

import java.util.*;      

//define class

public class Budget                      

{

public static void main(String [] a)            //define main method.

{

//creating Scanner class object.

Scanner ob =new Scanner(System.in);    

//define variable.      

double budgetamount=0, amountspent=0 ,difference=0,total=0,num=0 ;        

int count = 0;                            

System.out.println("How much have you budgeted for the month? :");        //print message.

budgetamount=ob.nextDouble();                             //taking input

       while(budgetamount != 0)           //checkig number greater then 4 digite.

       {

           budgetamount= budgetamount/10;        

           ++count;

       }

       if(count>4)                 //condition

       {

       System.out.println("enter each expense, then type -999 to quit: ");

       while(num!=-999)               //taking expense  

       {

       total=total+num;                 //totaling expense

       num=scan.nextDouble();                  

       }

       if(total<=budgetamount)           //condtion for over budget.

       {

       System.out.print("under budget:");         //print message

       System.out.print(budgetamount-total);

       }

       else

       {

       System.out.print("over budget:");              //for under budget

       System.out.print(total-budgetamount);

       }

       }

       else

       {

       System.out.println("not valid");        //message for number lessthen 4 digit.    

       }                                      

}

}

output:

How much have you budgeted for the month? : 1200.55.

enter each expense, then type -999 to quit: 365.89

556.90

339.98

-999

over budget:1262.77

Explanation:

The explanation of this program can be given as:

In the above program we import the package in that is used for scanner class. This class is used for the input from the user after input we use the while loop and if-else statement. The while loop is the entry control loop It is used for input validation and if-else is used for the checking condition. Then we insert expense that is inserted by the user. Then we calculate under-budgeted and over-budgeted by conditional statement that is if-else. and at the last we print it.

You might be interested in
A network administrator receives a call from the sales department requesting ports 20 and 21 be opened on the company’s firewall
emmainna [20.7K]

Answer:Document the reason for the request, Follow the company’s approval process for the implementation

Explanation:

The port 20 and 21 are used for the FTP connection, so before opening port 20 and 21 it is necessary to abide by the company data security policy which includes documenting the reason for the request and following company's approval process for its implementation.

8 0
3 years ago
a publication usually issued daily,weekly or other regular times that provides news,views,features and other information of publ
leonid [27]

Answer:

adsfafdfads

Explanation:

afdafdsa

8 0
2 years ago
Which part of project management considers if employees will work at home or in the office?
gregori [183]

Answer: i think its resources

Explanation:

5 0
2 years ago
Read 2 more answers
The roll out, roll in variant of swapping is used ____."
Sindrei [870]

Answer:

C.) for priority-based scheduling algorithms

Explanation:

for priority-based scheduling algorithms

4 0
2 years ago
A technician is buying a PC that will host three VMs running at the same time with the current configuration. The technician bel
raketka [301]

Answer:

B. SSD

Explanation:

VMs or virtual machines are virtually created environment for multiple operating system on a host operating system. The host operating system has an extension called Hyper-V. The hyper-V manager helps to manage the virtual machine's activities.

The VMs can hold applications in their respective containers, which requires a partition of the storage. So when more VMs are configured, more storage memory is required to store their individual data. The VMs in a computer system can share a network interface card.

7 0
3 years ago
Other questions:
  • Select all of the uses of presentation software in the workplace.
    8·1 answer
  • Write a Python program that will take as input 5 integer values and will output the average of the odd values and the average of
    6·1 answer
  • What’s good and bad about having social media?
    14·2 answers
  • Most hard drives are divided into sectors of 512 bytes each. Our disk has a size of 16 GB. Fill in the blank to calculate how ma
    9·1 answer
  • Describe how the presence or absence of balance can affect a visitor’s perceptions of a Web page.
    7·1 answer
  • How should work be allocated to the team in a Scrum project?
    13·1 answer
  • Who here has a crush on jk from bts but feels more mature than him
    10·2 answers
  • Any one know :) please
    9·1 answer
  • What will be displayed after this code segment is run?
    5·1 answer
  • Which of the following offers more reliable antivirus protection? Question 43 options: A) antivirus software on user PCs B) anti
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!