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
Anyone know this awnser computer science
jolli1 [7]

Answer:

Smartphones, Satellite internet providers, smart speakers, and bluetooth headphones

Explanation:

6 0
2 years ago
Read 2 more answers
What is TCP/IP's Transport layer's primary duty?
lorasvet [3.4K]

Answer:

 The TCP/IP is the transmission control protocol and internet protocol and in the TCP/IP model the transport layer is the second layer.

The primary responsibility of this layer is that it is basically used to deliver messages to the host and that is why it is known as end to end layer.

It basically provide the point to point connection between the destination to server host for delivering the various types of the services efficiently and reliably.

In the TCP/IP model the transport layer are basically responsible for transferring the data or service error free between the server to destination host.

3 0
3 years ago
What is the difference between auto fill and fill handle ?​
lidiya [134]

Answer:

  • Auto fill a software function that automatically completes data (like the data that has been entered previously) without the user needing to type it in full.

  • The Fill Handle is a feature in Excel that fills the data automatically with a specific pattern in your spreadsheet cell.

hope u liked the answer :)

7 0
2 years ago
What is the difference between First Person Shooters and Construction Simulations?
Marianna [84]

Answer:No clue

Explanation:

5 0
3 years ago
Read 2 more answers
Why is it important for element IDs to have meaningful names?
wlad13 [49]

Answer:

so a program can reference it; however, it does not necessarily need an event handler

Explanation:

8 0
3 years ago
Other questions:
  • Is anyone familiar in drawing flow charts for c++ programming
    14·1 answer
  • You have a folder on your Windows desktop system that you would like to share with members of your development team. Users need
    13·1 answer
  • Help please?
    10·1 answer
  • Write a Python program that translates a binary number of n bits to a decimal number. Your program should first ask the user the
    8·1 answer
  • Submit your business presentation that clearly compares and contrasts three different cell phone service plans..
    14·2 answers
  • Define the term hardwar<br><br>​
    9·2 answers
  • 4. In computers, an integer can be represented by more than 8-bit, what is the largest positive integer that
    9·1 answer
  • 100 POINTSSSSSSS!!
    5·1 answer
  • Html is a markup language that lets you identify common sections of a web page
    8·1 answer
  • Which website offers guidance on putting together a checklist to provide guidance on configuring and hardening operating systems
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!