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
KonstantinChe [14]
3 years ago
10

Write a Java program that has a static method named range that takes an array of integers as a parameter and returns the range o

f values contained in the array. The range of an array is defined to be one more than the difference between its largest and smallest element. For example, if the largest element in the array is 15 and the smallest is 4, the range is 12. If the largest and smallest values are the same, the range is 1.
Computers and Technology
1 answer:
SashulF [63]3 years ago
5 0

Answer:

The program in Java is as follows:

import java.util.*;

import java.lang.Math;

public class Main{

public static int range(int low, int high){

    return Math.abs(high - low)+1;

}

public static void main(String[] args) {

 Scanner scnr = new Scanner(System.in);

 int num1 , num2;

 System.out.print("Enter two numbers: ");

 num1 = scnr.nextInt();

 num2 = scnr.nextInt();

 System.out.print(range(num1,num2));

}

}

Explanation:

This defines the range method

public static int range(int low, int high){

This calculates and returns the range of the two numbers

    return Math.abs(high - low)+1;

}

The main begins here

public static void main(String[] args) {

 Scanner scnr = new Scanner(System.in);

This declares 2 numbers as integer

 int num1 , num2;

This prompt the user for two numbers

 System.out.print("Enter two numbers: ");

The next two lines get input for the two numbers

 num1 = scnr.nextInt();

 num2 = scnr.nextInt();

This calls the range function and prints the returned value

 System.out.print(range(num1,num2));

}

You might be interested in
How to download a software program??
Makovka662 [10]

Answer:

you can download any software program from the internet a preferred site is softonic.com

3 0
3 years ago
Lesson 2.7 Code Practice #2
scoundrel [369]

Answer:

no se ve unu ........unu

5 0
3 years ago
Complete the function to return the factorial of the parameter using recursion,
Dominik [7]

def recursiveFactorial(number):

   if number > 0:

       return number * (recursiveFactorial(number - 1))

   else:

       return 1

stringNum = input("Enter a positive integer: ")

num = int(stringNum)

print(recursiveFactorial(num))

I hope this helps!

5 0
3 years ago
Read 2 more answers
An index purports to speed data retrieval. you, therefore, index every attribute in each table. select the likely consequence.
stira [4]

Answer:

b. data entry slows as every INSERT , UPDATE, or DELETE statement must also update every index.

Explanation:

This process help to improve the speed of get data , it takes each element in the indexed column and save the location to get faster the data. But if you index every attribute in a table it going to take a lot of time locating each column in the respective index in each query(update, delete and insert). For that reason is necesary be carefull with this process and only put index in the relevant columns

4 0
3 years ago
In object-oriented analysis, an object is a member of a(n) _____, which is a collection of similar objects.
Advocard [28]

In object-oriented analysis, an object is a member of a CLASS, which is a collection of similar objects. It is a software engineering method.

<h3>Object-oriented analysis </h3>

Object-oriented analysis and design can be defined as a software engineering methodology.

This methodology (object-oriented analysis) is used to model a system as a particular group of interacting objects.

The object-oriented analysis is characterized due to the fact that objects are organized according to particular classes.

Learn more about object-oriented analysis here:

brainly.com/question/3522354

3 0
2 years ago
Other questions:
  • In number theory, a perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the
    12·1 answer
  • Which are malicious codes? <br><br> JavaScript <br> Key loggers <br> Scrum <br> Spyware <br> Worms
    12·1 answer
  • While a hard drive is running, even a slight bump against the computer may cause the
    9·2 answers
  • Hackers who gain control over several computers can organize them into a client-server network known as a(n) __________ . This n
    7·1 answer
  • What was one complication caused by the tsunami that struck japan in 2011?
    15·1 answer
  • Nested if-else structures can contain many blocks of code. How many of those blocks of code might be executed?
    14·1 answer
  • Which statistical function in a spreadsheet helps you to see how far each number varies, on average, from the average value of t
    5·1 answer
  • Select three advantages to using digital video.
    5·2 answers
  • Add me on blizzard none of my friends play ow<br> NADERJABER#2530
    8·1 answer
  • Explain how a stored procedure is processed by the DBMS query processor (including the type of return value after the query is p
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!