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
Refer to the method f: Public int f( int k, int n ) { if( n == k ) return k; else if( n &gt; k ) return f( k, n - k ); else retu
Debora [2.8K]

Answer:

Returned value: 2

Explanation:

Public int f(int k, int n) {

   if (n == k)

       return k;

   else if (n > k)

       return f(k, n - k);

   else return f(k - n, n);

}

/////////////////////////////////////////////////////////////////////////////////////////

Trace of function calls,

f(6, 8)

f(k, n - k) -> (6, 2)

f(k - n, n) -> (4, 2)

f(k - n, n) -> (2, 2)

return k

5 0
3 years ago
The voluntary linkage of computer networks around the world is called the ______.
77julia77 [94]
The voluntary linkage of computer networks around the world is called the internet which began to be used in the 1990s. It initially began being used in the 1960s by scientists with the aim of exchanging information about research. Between the year 1995 and late 2002, the number of those connected to the internet rose from 26 million to more than 600 million. Currently, internet has now become a way of life.








3 0
3 years ago
To open the dialog box for modifying styles, which step must you first complete in the Navigation pane?
castortr0y [4]
Sorry I do not know this. Maybe you can help me on it? 
7 0
3 years ago
Read 2 more answers
Having a good credit score is important because:
Lisa [10]
It would be better if we could see the options, fully. But from what I can see, it should be B.
7 0
3 years ago
Assign a variable solveEquation with a function expression that has three parameters (x, y, and z) and returns the result of eva
Arada [10]

Answer:

def func1(x, y, z):

   return z*3*y - x

x= int(input("Enter x"))

y= int(input("Enter y"))

z= int(input("Enterz"))

solveEquation=func1(x, y, z)

print (solveEquation)

Explanation:

Please check the answer section.

6 0
3 years ago
Other questions:
  • If you enjoy working with livestock, the best cluster in which to research careers would be: A. Health Science. B. Agriculture,
    11·1 answer
  • Analyze the following code. Number[] numberArray = new Integer[2]; numberArray[0] = new Double(1.5); Question 9 options: A) Sinc
    13·1 answer
  • Which term is defined as an exploit that takes place before the security community or software developer knows about the vulnera
    12·1 answer
  • (1) Output a menu of automotive services and the corresponding cost of each service. (2 pts)Ex:Davy's auto shop servicesOil chan
    9·1 answer
  • SLA:
    14·1 answer
  • A type of attack where the adversary intercepts network packets, modifies them, and inserts them back into the network is called
    13·1 answer
  • Which statement best describes the computers all around us?
    15·1 answer
  • The startup routine runs,when machine boots up is known as​
    6·2 answers
  • Aaaaaaaaaaaaaaaaplssssssssssssssssssssssssssssshelpppppppppppppppppppppppp
    11·2 answers
  • Create a program that prompts the user for a positive integer then prints a right-aligned pyramid using that number using the st
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!