QuestionQuestion

Write a program that has 3 public constants N = 100, Low = 20, Up = 1000. Using those constants, create an array name arrInt[] of N random integers in the range [Low, Up]. Write the following methods to:

+ Find the summation of all integers in the array.
+ Find the average, the maximum and minimum numbers of the array.
+ Double numbers in the 1st position, the 3rd position, the 6th, 9th, 12th, etc in the array.
+ Sort the array using bubble sort
+ Sort the array using selection sort
+ Ask the user for a key. Search for that key in the sorted array using sequential search
+ Ask the user for a key. Search for that key in the sorted array using binary search

Solution PreviewSolution 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.Arrays;

public class ArrayManip {

public final static int N = 100;
public final static int Low = 20;
public final static int Up = 1000;

public static void main(String[] args)
{
int[] arrInt = new int[N], arrCopy = new int[N];
for(int i = 0; i < N; i++)
{
arrInt[i] = (int)(Math.random() * (Up+1-Low) + Low);
System.out.print(arrInt[i] + " ");
}
System.arraycopy(arrInt, 0, arrCopy, 0, arrInt.length);
System.out.println("\nSum: " + arraySum(arrInt));
System.out.println("Average: " + arrayAvg(arrInt));
int[] newArr = doubleArrayPos(arrCopy);
for(int i = 0; i < N; i++)
{
System.out.print(newArr[i] + " ");
}
System.out.println();
System.arraycopy(arrInt, 0, arrCopy, 0, arrInt.length);
newArr = bubbleSort(arrCopy);
for(int i = 0; i < N; i++)
{
System.out.print(newArr[i] + " ");
}
System.out.println();
System.arraycopy(arrInt, 0, arrCopy, 0, arrInt.length);
newArr = selectionSort(arrCopy);
for(int i = 0; i < N; i++)
{
System.out.print(newArr[i] + " ");
}
System.out.println();
System.out.println("Index for key 20 (sequential): " + sequentialSearch(20, newArr));
System.out.println("Index for key 20 (binary): " + binarySearch(20, newArr));
}...
$13.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats