Question: can you complete java code for main method, just for what i write in bold Write a java program (xxxxxp1.java where xxxxx is the first

can you complete java code for main method, just for what i write in bold

Write a java program (xxxxxp1.java where xxxxx is the first five characters of your last name and p1 is the project number) that contains the following methods:

  1. A method that returns 2nd largest in an array with n elements.
  2. A method that prints (formatted) array elements 10 elements per line.
  3. A mergesort method that mergesorts array elements in descending order.
  4. A binary search method that searches x in a sorted array with n elements and returns its position if exist, -1 otherwise.

public static void main(String args[]) throws exception{

try{

Scanner inf = new Scanner (System.in);

n = inf.nextInt(); // read no. of input

xxxxxp1 p1 = new xxxxxp1 (n);

read n integers and store them in array arr and print arr(formatted) 10 elements per line. (40 pts)

find 2nd largest and print it. (40 pts)

mergesort array arr and print arr(formatted) 10 elements per line. (80 pts)

k = inf.nextInt(); // read no. of elements to search

read k keys to search using binary search and print their position in array arr. (40 pts)

}catch (Exception e) {prt(" Exception " + e + " ");}

}// end main method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!