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
Communication between a computer and a keyboard involves ______________ transmission.
4vir4ik [10]

Answer:

Simplex transmission

Explanation:

Communication between computer and keyboard involves which transmission? Answer: Simplex transmission requires communicating between a computer and a keyboard. The simple transmission & communication channel allows data from only one direction.

8 0
1 year ago
Your computer has two basic types of software: system software and ________ software.
Elan Coil [88]
Hi!

Our computers will have system software and application software. Application software would be something like a game or just any general purpose app you've downloaded.

Hopefully, this helps! =)
5 0
3 years ago
What is a characteristic of a wan hub-and-spoke topology?
olga nikolaevna [1]

The characteristic of the WAN hub and spoke topology is that it is considered to be a branch site or composed of the branch site in which they are likely to be connected to a site that is central and that is through the point to point links.

8 0
2 years ago
To test for the current date in a query, type ____ in the criteria row of the appropriate column.
lyudmila [28]

Answer:

zxc

Explanation:

zc

6 0
3 years ago
Tamara has $500 she is looking to save for a class trip. She wants to earn the most possible interest and will not need access t
Novay_Z [31]
Certificate Of Deposit- It will be unaccesible and will help her the best.
6 0
3 years ago
Read 2 more answers
Other questions:
  • Define the method object inc_num_kids() for personinfo. inc_num_kids increments the member data num_kids. sample output for the
    11·1 answer
  • TRUE OR FALSE, databases allow you to search for content on the internet based on certain criteria (PLS ANSWER RIGHT)
    10·2 answers
  • Sonora wants to extend the cells to be added in her formula. what is the quickest way to add more sells?
    10·2 answers
  • Write the percentage 5 1/4 as a decimal​
    8·1 answer
  • You are given 6 training examples for a binary classification problem as follows:
    12·1 answer
  • Select the correct answer.
    13·1 answer
  • What are specific and relevant terms that will help you locate information using an internet search engine?
    10·1 answer
  • Consider the following method.
    14·1 answer
  • drag each type of document to the correct location on the table. Drag each document to its respective category
    7·1 answer
  • Are there any Potential Dangers in Artificial Intelligence?
    11·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!