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
Rewrite the Espresso Counter program to Swap or interchange any two rows of the output. Copy and paste just the interchanged par
seraphim [82]

Answer:

Rewrite the Espresso Counter program to Swap or interchange any two rows of the output. Copy and paste just the interchanged parts of the code. Compile and run the modified program. Copy and paste the new user interface output. Add a new row to the Espresso Counter user interface. Describe your modifications. Compile and run the new program. Copy and paste

1. Your modifications

2. Snapshots of your new counter interface.

4 0
2 years ago
Does anybody have the answer for 2.19.6 checkerboard for codehs??
ANTONII [103]

Answer:

speed(0)

penup()

setposition(-200,-200)

pendown()

def draw_square_row():

color_value = 0

for i in range (10):

if color_value %2 == 0:

begin_fill()

color("red")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

elif color_value %2 == 1:

begin_fill()

color("black")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

def draw_square_row_2():

color_value = 1

for i in range (10):

if color_value %2 == 0:

begin_fill()

color("red")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

elif color_value %2 == 1:

begin_fill()

color("black")

for i in range (4):

forward(40)

left(90)

forward(40)

color_value = color_value + 1

end_fill()

def move_up_a_row():

left(90)

forward(40)

right(90)

backward(400)

for i in range (5):

draw_square_row()

move_up_a_row()

draw_square_row_2()

move_up_a_row()

Explanation:

tell me if you get it right

5 0
2 years ago
Creating a Venn diagram takes specialized computer software.
DerKrebs [107]

Answer:

F

Explanation:

false because you don't need a computer software to make a venn diagram you can make one

8 0
3 years ago
Read 2 more answers
Which option organizes tasks based on importance?
crimeas [40]

The correct answer is B. Prioritized view

Explanation:

The word "priority" is used to describe events, places, people, etc. that are considered of great importance. This means a task that is considered a priority is more important than regular tasks. In this way, in management software such as Outlook that allows users to monitor and manage tasks or things to do, users can organize tasks based on importance by clicking options such as "prioritized" or "prioritized view" that will display task from the most important to the least important. Thus, the option that organizes tasks based on importance is the prioritized view.

7 0
3 years ago
A large amount of data is stored in secondary storage is it true<br>​
Mice21 [21]
Since it’s more cost efficient, it’s better to store more data in the secondary storage. Yes true!
6 0
3 years ago
Read 2 more answers
Other questions:
  • A file must be ________ before data can be written to or read from it. closed opened buffered initialized none of these
    11·2 answers
  • 8. A pattern of being late for work or for appointments is usually
    12·1 answer
  • 1. compression
    11·1 answer
  • PLEASE HELP ME ASAP!!!!
    11·1 answer
  • What does f.i.r.s.t stand for in robotics
    15·1 answer
  • Subana is writing a program which will calculate the mean average of a set of numbers by adding the numbers and dividing the res
    11·2 answers
  • Write a program to randomly fill an array of float of 10 elements (use the rand() function and make sure to use #include ) in ma
    11·1 answer
  • Describe how data is transmitted using half-duplex serial data transmission.
    9·1 answer
  • Write a program that inputs numbers and keeps a running sum. When the sum is greater than 100, output the sum as well as the cou
    8·1 answer
  • A technique that was developed to determine whether a machine could or could not demonstrate the artificial intelligence known a
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!