Computers and Technology

Write a Java program that asks the user to enter an array of integers. The program should prompt the user for the number of elements in the array and then the elements of the array. Theprogram should then call a method named minGap that accepts the array entered by the user as a parameter and returns the minimum 'gap' between adjacent values in the array. The main method should then print the value returned by the method. The gap between two adjacent values in an array is defined as the difference in value between the first element and the secondelement. For example, suppose the user entered the following array of integers {1, 3, 6, 5, 12}The first gap is 2 (3 - 1), the second gap is 3 (6 - 3), the third gap is 1 (6 - 5) and the fourth gap is 5 (12 - 6). Thus, the call of minGap(array) should return 1 because that is the smallest gap in the array. If you are passed an array with fewer than 2 elements, you should return 0.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:00, jabezslade22
What is the first view you place in your drawing?
Answers: 1
image
Computers and Technology, 23.06.2019 04:10, cvbnkifdfg
2pointswho was mikhail gorbachev? oa. a russian leader who opposed a coupob. a polish leader who founded the labor union "solidarityoc. a soviet leader who called for a closer relationship with the unitedstates, economic reform, and a more open societyd. a soviet leader who called for more oppression in the soviet union
Answers: 3
image
Computers and Technology, 23.06.2019 14:30, ladawnrowles005
The option enables you to modify a slide element in most presentation applications.
Answers: 2
image
Computers and Technology, 23.06.2019 15:00, herchellann302
To check whether your writing is clear , you can
Answers: 2
Do you know the correct answer?
Write a Java program that asks the user to enter an array of integers. The program should prompt the...

Questions in other subjects:

Konu
Biology, 07.04.2020 23:15
Konu
Mathematics, 07.04.2020 23:15
Konu
English, 07.04.2020 23:16