Write a java program named ArraysExercise.java including the following methods: 1. [2 marks] Write a method named getArray that initializes an array of n integer from user input and returns the array....

1 answer below »
computer science quiz


Write a java program named ArraysExercise.java including the following methods: 1. [2 marks] Write a method named getArray that initializes an array of n integer from user input and returns the array. 2. [2 marks] Write a method named printArray that given an array of integers, prints the array in a tabular format with 5 number in each line. 3. [3 marks] Write a method named findMax that given an array of integers finds and returns the maximum value in the array. 4. [3 marks] Write a method named findMin that given an array of integers finds and returns the minimum value in the array. 5. [3 marks] Write a method named findMaxIndex that given an array of integers finds and returns the index of maximum value in the array. 6. [3 marks] Write a method named findMinIndex that given an array of integers finds and returns the index of minimum value in the array. 7. [3 marks] Write a method named isSortedAscend that given an array of integers, it checks whether array is sorted in ascending order. 8. [3 marks] Write a method named isSortedDescend that given an array of integers, it checks whether array is sorted in descending order. 9. [5 marks] Write a method named swapNeighbor that given an array, it compares every two neighbor numbers in the array (eg. A[i] and A[i+1]) and swaps them if A[i] is more than A[i+1]. It finally passes the new changes to the caller method. For example, for the given array {12, 9, 15, 7, 3}, as the result of calling swapNeighbor, the array must be changed to {9, 12, 7, 3, 15}. 10. [5 marks] Write a method named merge that given two arrays sorted in ascending order, it merges them into one sorted array in ascending order. For example, if the given arrays are {2, 6, 9} and {-1, 5, 11, 12}, then the merged array must be {-1, 2, 5, 6, 9, 11, 12}. there is one big questions with 10 small part the quiz will give you the other 9 questions and only one you need to fit in or it will give you the whole part and fing something mistake and fix it the other questions is just mc questions Quiz test , vancouver time 8:35-10:00 , java 10-20 mcq questions
Answered Same DayMar 23, 2021

Answer To: Write a java program named ArraysExercise.java including the following methods: 1. [2 marks] Write a...

Swapnil answered on Mar 24 2021
150 Votes
class XYZ
{
public static void print2largest(int a[], int a_size)
{
int i, firs
t, sec;
if (a_size < 2)
{
System.out.print(" Invalid Input ");
return;
}
first = sec = Integer.MIN_VALUE;
for (i = 0; i <...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here