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
Sergio039 [100]
2 years ago
14

Write a method getIntVal that will get the correct value input as integer numbers from the user. The input will be validated bas

ed on the first two numbers received as parameters. In other words, your program will keep asking for a new number until the number that the user inputs is within the range of the and . The method should show a message asking for the value within the range as:
Computers and Technology
1 answer:
Setler [38]2 years ago
4 0

Answer:

 import java.util.Scanner;

public class Main

{  

   //Create a Scanner object to be able to get input

   public static Scanner input = new Scanner(System.in);

   

public static void main(String[] args) {

    //Ask the user to enter the lowest and highest values

    System.out.print("Enter the lowest: ");

    int lowest = input.nextInt();

    System.out.print("Enter the highest: ");

    int highest = input.nextInt();

   

    //Call the method with parameters, lowest and highest

    getIntVal(lowest, highest);

}

//getIntVal method

public static void getIntVal(int lowest, int highest){

    //Create a while loop

    while(true){

        //Ask the user to enter the number in the range

        System.out.print("Enter a number between " + lowest + " and " + highest + ": ");

        int number = input.nextInt();

       

        //Check if the number is in the range. If it is, stop the loop

        if(number >= lowest && number <= highest)

            break;

        //If the number is in the range,

        //Check if it is smaller than the lowest. If it is, print a warning message telling the lowest value

       

        if(number < lowest)

            System.out.println("You must enter a number that is greater than or equal to " + lowest);

        //Check if it is greater than the highest. If it is, print a warning message telling the highest value

        else if(number > highest)

            System.out.println("You must enter a number that is smaller than or equal to " + highest);

    }

}

}

Explanation:

*The code is in Java.

You may see the explanation as comments in the code

You might be interested in
A __________ note is a private note that you leave for yourself or for other people who might use the presentation file
BaLLatris [955]

Answer:

The answer is that it is a speaker note.

Explanation:

It leaves a note for people that use presentation files. I use it all the time on my google slides.

7 0
2 years ago
Como se juega robótica de cokitos
Anton [14]

Answer:

No sé.

Explanation:

Especifica más.

4 0
2 years ago
Choose the correct statement:_______.
olga2289 [7]

Answer:

d. A String is a class data type so a String variable holds a reference to a location in memory

It depends on which programing language or scripting language...

Explanation:

If it's Java then D is the correct answer...

6 0
2 years ago
Hey guys... so my dad reset my history on my laptop, and now when i try to login to discord it says "new login location detected
igor_vitrenko [27]

Answer:

do nothing it will happen itself

8 0
3 years ago
Read 2 more answers
Which statement is correct about operating systems? They are hardware devices. They include programs that help people do certain
katrin2010 [14]
<span>They include programs that help people do certain tasks. They include programs that control a computer. They store information being used by the CPU.</span>
3 0
2 years ago
Other questions:
  • What car dealership websites did you use to conduct your research?​
    8·1 answer
  • _____ is when network managers deal with network breakdowns and immediate problems instead of performing tasks according to a we
    9·1 answer
  • Which of the following is NOT an example of a font style?
    13·1 answer
  • The domain in an email message tells you the
    5·1 answer
  • When a formula contains the address of a cell, it is called a(n) ________.
    15·1 answer
  • Write a function all_cats that consumes a comma-separated string of animals and prints whether all of the animals have "cat" in
    12·1 answer
  • Visual-verbal synergy has nothing to do with text, but solely with images used in a design.
    9·1 answer
  • _____________________________________________________is a pre-designed format to help users with the creation of a document, lik
    6·1 answer
  • An epic games service is unavailable at the moment
    8·1 answer
  • Memory containing hardwired instructions that the computer uses when it boots up, before the system loads. In PCs the instructio
    9·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!