# use javaDevelop a program which allows the user to enter numbers into an array. Input will be as follows: The user will enter the total number of integers to be entered into the array. The user will then enter that number of unique integers (negative or positive). Do not allow the number of values entered to exceed the array size.Develop methods to:‘main’ method.Print the arraySort the array ( YOU MUST DEVELOP YOUR OWN SORT METHOD – don’t use someone else’s or API classes)Determine the highest valueDetermine the lowest valueCalculate the average value (double)use bubble sort ***

Question
37 views

use java

Develop a program which allows the user to enter numbers into an array. Input will be as follows: The user will enter the total number of integers to be entered into the array. The user will then enter that number of unique integers (negative or positive). Do not allow the number of values entered to exceed the array size.

Develop methods to:

‘main’ method.

Print the array

Sort the array ( YOU MUST DEVELOP YOUR OWN SORT METHOD – don’t use someone else’s or API classes)

Determine the highest value

Determine the lowest value

Calculate the average value (double)

use bubble sort ***

check_circle

Step 1

To develop this program  ,first of all you import  java.util.Scanner package in  which Scanner class is declared. The Scanner class is used to get user input.

To use the Scanner class, create an object of the class and use any of the available methods found in the Scanner class documentation. In our example, we will use the nextInt () method, which is used to read integer values as follows:

import java.util.Scanner;

public static void main(String[] args) {

int n;
Scanner s = new Scanner(System.in);
System.out.println("enter the number for array size");
n = s.nextInt();
int[] array = new int[n];
System.out.println("please enter the elements of array");

for (int i = 0; i < array.length; i++) {

array[i] = s.nextInt();
}

In our program we use an Array. An array is a group of like-typed variables that are referred to by a common name.After that

You  enter the size of the array and then we use for  loop for entering the elements of array which do not allow the number of values entered to exceed the array size.

Step 2

Now we call the printArray(array) method that prints the values of an array which is entered by the user as shown below:-

public static void main(String[] args) {

int n;
Scanner s = new Scanner(System.in);
System.out.println("enter the number for array size");
n = s.nextInt();
int[] array = new int[n];
System.out.println("please enter the elements of array");

for (int i = 0; i < array.length; i++) {

array[i] = s.nextInt();
}
printArray(array);
}
The code of printArray(array) method is shown in image as:
Step 3

After that we call the sortArray (array) method that sorts the elements of an array using bubble sort:-

public static void main(String[] args) {

int n;
Scanner s = new Scanner(System.in);
System.out.println("enter the number for array size");
n = s.nextInt();
int[] array = new int[n];
System.out.println("please enter the elements of array");

for (int i =...

### Want to see the full answer?

See Solution

#### Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.
Tagged in

### Computer Science 