Question
Here are the detail descriptions for project on eclipse: First create a new Eclipse Java project named JohnDoeprj and then inside this project, create a
Here are the detail descriptions for project on eclipse:
First create a new Eclipse Java project named JohnDoeprj and then inside this project, create a new class named JohnDoeprj.java. Replace JohnDoe with your first and last name.
n its main method, provide a line like this as the first line inside the main method, which outputs your name, work, such as :
System.out.println("John Doe, google");
No GUI is needed in this homework. No console input is needed, thus no need to import Scanner class.
In the main method, then follow the STEPS below:
Declare an array of double type, with size 10.
Use a regular for loop to generate 10 random double type variables and fill them into the array. The range of the random variables is between 0 and 100, including 0 and excluding 100. Use method Math.random().
Invoke a method named printArray in the same class, to print all elements of this array in one line, with a space separating adjacent array elements, and then output an end-of-line symbol at the end. You should use printf method to specify the output to have only 2 digits after the decimal point for each double type variable. This method printArray takes only one parameter, which is a double type one-dimensional array, and the method return type should be void. Use a for-each loop in this method to navigate through the array.
Invoke a method name sort in the same class, to sort this array in decreasing order. This method takes only one parameter, which is a double type array, and its return type should be void. You must choose one of these three algorithms: selection, insertion, or bubble sort.
Invoke method printArray again to print the array to the screen, to verify that it has been sorted.
Implementation requirements:
In class JohnDoePrj.java, you should have three methods. One is the main method, the second method is printArray. , and the third is sort. Do not put more classes or more methods in the homework, o/w, you are in the wrong track.
Inside the main method, you invoke method printArray and sort.
The signatures of method printArray and sort have already been defined in step 3 and 4 above, and you cannot change the signature nor the return type of this method
Because the required sort order in this project is decreasing order, you need to make a modification on the sorting algorithm provided in the file search-and-sorting.zip (they are all increasing sort). Hint: just change the comparator before the swap operation will change the sort order from increasing to decreasing. Again, as stated in Step 4 above, you can choose which sorting algorithm to use.
Add some suitable comments in the source code.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started