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
Do you really think our life applications and OSs will be open source at the end for everything?
algol [13]

Answer:

 Yes, the given statement is true because the life applications like various networking application and computer and television shows are basically operated and monitored by various OSS  (operational support system).

The open source basically refers to the system which is open for all so that everyone can easily contribute. The operational support system handle all the applications based on our daily life. By proper analyzing the operational system so that it provide efficient output and various resources.

Therefore, various life application and operational system are open source.  

4 0
2 years ago
A rang check that could be use to validate... Date and time
lisov135 [29]

A range check is often used when a person works with data consisting of numbers, dates and times, or currency, ensuring that a number is within a specific range.

Explanation:

  • Range checks allow a person to set suitable boundaries.
  • An example of a range check is checking to see if the value of a 16-bit integer is within the capacity of a 16-bit integer. When a range check is performed, upper and lower boundaries are specified.
  • Range check is a validation check which can be applied to numeric fields. This is done to ensure that only numbers within a certain domain can be entered into a field. Remember that this does not necessarily mean that the data entered will be correct. But it will certainly lie within reasonable limits.
  • A method of validation which checks that data falls between an upper and lower acceptable value.
  • This validation check which can be applied to numeric fields. This is done to ensure that only numbers within a certain domain can be entered into a field. Remember that this does not necessarily mean that the data entered will be correct. But it will certainly lie within reasonable limits.
5 0
3 years ago
Structured walk-throughs take place throughout the SDLC and are called _____ reviews, depending on the phase in which they occur
Tpy6a [65]

Answer:

design

Explanation:

Based on the information provided within the question it can be said that these are called design reviews. This is one of the most important parts of the development of a system. This focuses more on answering how something is going to be done in the system as opposed to answering what is going to be done for the system depending on the questions asked in the analysis phase.

5 0
2 years ago
Which collaboration website is best suited for social collaboration? www.media.iearn.org/projects www.meetup.com www.quest.nasa.
olga55 [171]
The first option is the correct answer
6 0
3 years ago
K
ollegr [7]
True??????????????????????????
7 0
3 years ago
Read 2 more answers
Other questions:
  • Data arranged and stored in a data set
    9·1 answer
  • What does email etiquette mean?
    14·1 answer
  • Which technique will NOT help you build rapport with your colleagues?
    15·1 answer
  • Something I should look for when trying to decide if a source is credible is the publication's ....
    10·1 answer
  • Para ti que es el sexting​
    11·1 answer
  • A local bank has just one branch. It sets up a peer-to-peer network for all devices on the system. The bank would like to be abl
    8·2 answers
  • Create a file name that to ensure the that the file is easy to find
    12·2 answers
  • You can resize a row in a table by dragging the ____.
    13·1 answer
  • __________ is a broad class of software that is surreptitiously installed on a user's machine to intercept the interaction betwe
    6·1 answer
  • Which of these would be the fastest transition duration?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!