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]
3 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]3 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
Which deployment tool will you use to deploy metadata from one organization to another organization?
jenyasd209 [6]
The answer is Force.com IDE or Unmamaged packages
7 0
3 years ago
What is a mechanical gear and how does it work to create more power?
Neko [114]
Its a gear that is not turned manually and it can spin faster and longer than a manual gear.
5 0
3 years ago
Suppose Host A wants to send a large file to host B. The path from Host A to Host B has three links, of rates R1 = 500 kbps, R2=
Lorico [155]

Answer:

The answer is 500 kbps

Explanation:

Consider the given data in the question.

R1 = 500 kbps

R2=2 Mbps

R3 = 1 Mbps

Now as it is mentioned that there is no other traffic in the network.

Thus,

throughput of the file = min {R1,R2,R3}

throughput of the file = min {500 kbps, 2 Mbps, 1 Mbps}

T/P of the file = 500 kbps

7 0
3 years ago
Which of the following options would you use when saving a document with a new filename? *
Paha777 [63]
Save As, or Save A Copy.
3 0
4 years ago
Read 2 more answers
What is the correct sequence of processing instructions in a machine cycle?
Aleks04 [339]

Answer:

The four-step process of fetch, decode, execute, and store. Type of memory where the contents of this are not erased when the computer is turned off.

7 0
3 years ago
Other questions:
  • Users of an extranet can access a company or organization’s entire intranet
    8·2 answers
  • which type of website would a business selling merchandise on the internet use? A person B information C commercial D social
    9·1 answer
  • How to the inverse function of f(x)=x2 +1 ,x&gt;o
    5·1 answer
  • Which strategies should you follow if you begin to feel fatigued while driving
    12·2 answers
  • Why do local variables lose their values between calls to the function in which they are
    5·1 answer
  • Steven, Marcos, and Juan are having a free-throw shooting contest. Each boy
    9·1 answer
  • Which statements accurately describe the Bookmark feature in the Audio/Video control bar? Check all that apply.
    13·1 answer
  • PLEASE HURRY!!!!!!!!!! WILL MARK BRAINLIEST!!
    13·1 answer
  • Which of the following best describes how to measure the spread of the data? a) The IQR is a better measure of spread for badmin
    5·1 answer
  • Who is the father of computer?<br>1.Charles Babbage 2.James Waat​
    15·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!