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]
3 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]3 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
If you are feeling sick and you want to drive somewhere, you should
Ganezh [65]

Answer

Ask someone to drive you.

Explanation

When feeling ill, or even taking medication before driving Is dangerous for the driver and other road users  because it slows reactions and the ability to make rapid corrective actions while driving. Driving while sick  can also have the same effects on a driver as if they were drinking.

5 0
3 years ago
Read 2 more answers
What is one purpose of an algorithm
adelina 88 [10]

Answer:

Algorithms is formula for solving a problem. It is helpful because it specifically give instructions detail to computer to what a computer should perform a specific task.

For e.g. calculating report cards.

4 0
3 years ago
What is the correct sequence of the phases in the systems development life cycle?
HACTEHA [7]
1. Requirements gathering/analysis.
2. Design.
3. Development.
4. Testing.
5. Maintenance.
7 0
3 years ago
Which of these improved the ability to send information over the network in the 1970s?
frez [133]

Answer:

b. ethernet

Explanation:

It was an ethernet that was developed in the 1970s that improved the ability to send the information over the network. It is the most widely used method to connect the computers in a LAN or the local area network, ever since 1980 when it was first introduced for commercial use. And it is being used in bulk even today.

4 0
3 years ago
Another method that might be desired is one that updates the Student's number of credit hours. This method will receive a number
statuscvo [17]

Answer:

Option d is the method

Explanation:

public void update Hours(int more Hours)

{

hours += more Hours;}e. public int update Hours(int more Hours){return hours + more Hours;

}

5 0
3 years ago
Other questions:
  • What tool listed below will be the most useful for developing presentation content?
    10·2 answers
  • What are examples of some Exotic currencies?
    14·1 answer
  • The rod and crankshaft convert the up-and-down motion of the piston into
    5·2 answers
  • You are a disgruntled employee with a master’s degree in computer sciences who was recently laid off from a major technology com
    11·1 answer
  • Why might your digital footprint be important when you are applying for collage
    13·1 answer
  • Which actions help to protect a computer and keep it running properly? Check all that apply.
    10·1 answer
  • ___ involves connecting geographically remote computers into a single network and combining the computational power of all compu
    14·1 answer
  • What is the Purpose and function of the Global Positioning System (GPS)?
    7·1 answer
  • What is the most vulnerable information that should be protected to prevent unauthorized access to your online files and records
    8·1 answer
  • What is a software program for navigating the web and displaying websites and pages?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!