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
Give a pseudo-code description of the O(n)-time algorithm for computing the power function p(x,n).Also draw the trace of computi
laila [671]

Answer:

p(x,n)

1. if(n==0)    [if power is 0]

2.    then result =1.

3.else

4. {    result=1.

5.      for i=1 to n.

6.          {  result = result * x. }  [each time we multiply x once]

7.       return result.

8.  }

Let's count p(3,3)

3\neq0, so come to else part.

i=1: result = result *3 = 3

i=2: result = result *3 = 9

i=2: result = result *3 = 27

Explanation:

here the for loop at step 4 takes O(n) time and other steps take constant time. So overall time complexity = O(n)

6 0
3 years ago
​______________________ is a general security term that includes computer​ viruses, worms, and trojan horses.
VashaNatasha [74]
Malware
-------------------
6 0
3 years ago
B. List any four major drawbacks of the first generation computer​
d1i1m1o1n [39]

Answer:

Terribly low storage space, limited to mathematics/computing, required entire rooms to use, and low information yield for hours of processing.

Explanation:

3 0
2 years ago
What is the difference between an html opening tag and a closing tag?.
Doss [256]

Answer:

Explanation:

Generally speaking, there are two kinds of tags - opening tags: <html> and closing tags: </html>. The only difference between an opening tag and a closing tag is the forward slash "/". You label content by putting it between an opening tag and a closing tag.

HTML is all about elements.

7 0
1 year ago
A(n) ____ is an attack that takes advantage of a system vulnerability.
jarptica [38.1K]
<span>Exploit -</span> An attack that takes advantage of a system vulnerability, often<span> due to a combination of one or more improperly configured services.</span>
8 0
3 years ago
Other questions:
  • Constructors have the same name as the ____.1. data members2. member methods3. class4. package
    5·1 answer
  • ​User documentation _____. Group of answer choices ​allows users to prepare overall documentation, such as process descriptions
    9·1 answer
  • The introduction of new information technology has a: A. dampening effect on the discourse of business ethics. B. waterfall effe
    14·1 answer
  • Write a Java program that generates GUI (Graphical User Interface). Your program should provide labels and textfields to a user
    9·1 answer
  • Imagine you are responsible for making a presentation that includes a representation of the logic flow through a process. You un
    11·1 answer
  • Which is a benefit of using the paste link option?
    15·2 answers
  • While reading difficult content, you should always start witha.Surveying the chapterc.Reading the chapterb.Defining vocabulary w
    8·1 answer
  • PLEASE HURRY!!!
    11·1 answer
  • Python 3 (not java)1.Assume that word is a variable of type String that has been assigned a value. Write an expression whose val
    14·1 answer
  • how does a demilitarized zone (dmz) work. A.By preventing a private network from sending malicious traffic to external networks
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!