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
sashaice [31]
3 years ago
11

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 us

er 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.
Computers and Technology
1 answer:
Dominik [7]3 years ago
4 0

Answer:

import java.util.*;

public class Main {

public static void main(String[] args)

{

Scanner scan = new Scanner();

double budget=0, num=0, total=0;

System.out.println("Your budget for the month? ");

budget=scan.nextDouble();

System.out.println("enter all expense, and after that type -9999 to quit: ");

while(num != -9999)

{

total+=num;

num=scan.nextDouble();

}

if(total<=budget)

{

System.out.println("under budget by ");

System.out.println(budget-total);

}

else

{

System.out.println("over budget by ");

System.out.println(total-budget);

}

}

}

Explanation:

  • Take the budget as an input from user and store it to the budget variable.
  • Loop until user has entered all his expenses and keep on adding them to the total variable.
  • Check If the total is less than or equal to budget or otherwise, and then print the relevant message accordingly.
You might be interested in
The field that uses technology to manipulate and use information to improve healthcare is known as:_______
Sergeu [11.5K]

Answer:

Health informatics

Explanation:

7 0
1 year ago
Which character goes at the end of a line of code that starts with if?
weqwewe [10]

Answer:

Explanation:

tttttttttttt

4 0
2 years ago
How to do this PLEASE HELP 80 points!
sp2606 [1]

When reading the story, you know that the code has been created by humans, so it might actually be english and use concepts like our number system, our computer code system (I'm thinking ASCII), things that you should not assume when decoding a real alien message.

Looking at the numbers I notice that digits 6 to 9 do not occur in the message, which is statistically unexpected. This leads me to believe the number base might be 6 rather than our common base 10. In the story there are insects mentioned. Insects have 6 legs, so this makes sense (after all, our base 10 was based on the number of fingers).

Next, I notice the code 052 appearing regularly, so that could be a space. Let's check a hypothesis. 052 in base 6 is 5*6+2 = 32. 32 is the ASCII code for a space!!

Now, a decoding algorithm is ready to be devised:

"for each number in the sequence, parse it as a base-6 number and then print out its corresponding ASCII value".

The following node.js snippet does this:

var code = ['220','241','255','245','052','313',

           '311','052','312','303','052','312',

           '252','245','052','205','241','251',

           '253','243','052','203','253','302',

           '251','244','303','301','053'];

           

var msg = "";

for (let n of code) {

   msg += String.fromCharCode(parseInt(n,6));

}

console.log(msg);


And the message is.........:

<em>Take us to the Magic Kingdom!</em>

So, do these aliens want to visit Disneyland????

5 0
2 years ago
All of the following can be caused by the movement of geologic plates EXCEPT
Aleks04 [339]
I think storm surges cause fro means world "earth" so a storm surge is like a flood SO plates would cause earth quakes and stuff
8 0
3 years ago
At what depth does an employer need to use a protection system to ensure the safety of workers in a trench or excavation?
nevsk [136]
Trench 4 foot or deeper and must be located 25 foot within eachother
3 0
3 years ago
Read 2 more answers
Other questions:
  • How many valence electrons are present in the atom of the atomic number of 12?
    10·1 answer
  • Add is a function that accepts two int parameters and returns their sum.
    8·1 answer
  • What is the benefit to displaying the merge codes in a document?
    9·1 answer
  • ListenListen with ReadSpeakerAn administrator working on a Windows Server 2016 Server Core installation needs to disable DHCP on
    9·1 answer
  • 1. Consider a direct-mapped cache that can accommodate 8Mbytes from a main memory, that uses a 32-bit address and 32-byte blocks
    5·1 answer
  • Pls help me
    5·1 answer
  • Write a program that reads from a file called dictionary.txt which contains pairs of English and translated words separated by a
    12·1 answer
  • What are the advantages to using a linked implementation as opposed to an array implementation?
    8·1 answer
  • The first commercially available digital camera was which of the following?
    9·1 answer
  • FOR DIGITAL DESIGN/ PHOTOGRAPHY
    5·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!