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
Asked Apr 10, 2019
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

Expert Answer

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: 
fullscreen
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 =...
fullscreen

Want to see the full answer?

See Solution

Check out a sample Q&A here.

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

Engineering

Computer Science

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A
add
question_answer

Q: I need to be find the result of typing: len("Grand Hotel" [:6] . rstrip()) into Python. I constantly...

A: To find the result of the statement len("Grand Hotel" [:6] . rstrip()), you need to use print() func...

question_answer

Q: You are not required to execute the queries. However, your syntax must by accurate.You must give at ...

A: 8.SELECT MOVIE_TITLE, MOVIE_YEAR, PRICE, PRICE_RENTAL_FEE FROM MOVIES WHERE MOVIE_CATEGORY = 'FAMILY...

question_answer

Q: Write a complete C++ program that does the following:1. Create a 2-dimensional array with 8 rows and...

A: 1)Program plan:Declare the variables “rows” and “cols” as integerAssign “rows” to “8” and “cols” to ...

question_answer

Q: Let L1 = L (a∗baa∗) and L2 = L (aba∗). Find L1/L2.

A: Solution:Given that,Input: L1= L(a*baa*) and L2 = L(aba*) Output: Determine the L1/L2.We take all st...

question_answer

Q: I need help answering the following quetions I am not good with code. 1. Describe how you use TCP Du...

A: Use the keyword tcpdump with the TCP Dump flag –D.The flag –D will list all the interfaces that are ...

question_answer

Q: Please write Lisp code for the following problem. Write a function that computes the surface area of...

A: Instructions to create a function that computes the surface area of a cylinder:Define a function nam...

question_answer

Q: 4.23 (Financial application: payroll) Write a program that reads the following information and print...

A: C code#include&lt;stdio.h&gt;#include&lt;string.h&gt; int main(){char employeeName[20]="";double hou...

question_answer

Q: Programming in C language.

A: In order to implement the question mentions a method called getChoice() information about which has ...

question_answer

Q: in Operating System1.Why are two modes (user and kernel) needed?2.What are the steps performed by an...

A: Reasons why two modes are needed in OS:The two modes of OS are user mode and kernel mode. The user m...