subject

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.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 19:30
Raveena is making a professional presentation for a newly launched product of her company. she wants to incorporate the following features in her presentation. a) to add serial numbers in each slide b) to add name of her company on top of each slide. c) to add the picture of her product on the second slide(the picture of her product is stored on her computer) write the commands/features of her presentation tool using which she can perform the above operations.
Answers: 2
question
Computers and Technology, 22.06.2019 17:30
Which tab should you open to find the option for adding a header?
Answers: 1
question
Computers and Technology, 22.06.2019 21:30
This graph compares the total cost of attending educational institutions in texas. the graph demonstrates that the cost at private and public technical schools greatly varies.
Answers: 2
question
Computers and Technology, 23.06.2019 01:30
Jason works as an accountant in a department store. he needs to keep a daily record of all the invoices issued by the store. which file naming convention would him the most? a)give the file a unique name b)name the file in yymmdd format c)use descriptive name while naming the files d)use capital letters while naming the file
Answers: 3
You know the right answer?
Write a Java program that asks the user to enter an array of integers. The program should prompt the...
Questions
question
Mathematics, 12.11.2020 18:30
question
Mathematics, 12.11.2020 18:30
question
Mathematics, 12.11.2020 18:30
Questions on the website: 13722363