Question
Write an application that allows you to initialize and fill in a one-dimensional array of 12 double numbers. (These numbers should be taken as a user’s input). Create and use the custom method to sort the array values in a descending order. (Do not use any of the prebuilt sorting methods of the Array class—any sort type can be implemented, such as bubble sort). Write a separate method that will take the sorted array as an argument and display all of its elements.
Assignment 2:
Write a Java program which defines unconstrained array of user defined length n (the value of n is to be taken from a proper user’s input). Fill in the array with n random numbers. The application should (1) display all elements of the array, (2) display the sum of all elements, and (3) calculate the average of all elements.
Random numbers need to be generated inside the program making use of the prebuilt Java Random numbers generator available in the Math library class.
Solution Preview
This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.
import java.util.Scanner;public class Assignment1 {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
//initialize and fill in a one-dimensional array of 12 double numbers
double [] number = new double[12];
System.out.println("Enter 12 numbers : ");
Scanner console = new Scanner(System.in);
//(These numbers should be taken as a user’s input)
for (int i = 0; i < number.length; i++) {
number[i] = console.nextDouble();
}...