Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write Java program with a single-dimensionarray that holds 10 integer numbers and identify the maximum value of the 10 numbers. Next sort the array using

Write Java program with a single-dimensionarray that holds 10 integer numbers and identify the maximum value of the 10 numbers. Next sort the array using a bubble sort and display the array before and after sorting.

Step 1. Create algorithm (either flowchart or pseudocode) that you will use to write the program.Place the algorithm in a Word document.

Step 2. Code the program in Eclipse and ensure the following steps are accomplished.

1.Generate 10 random integer numbers between 1 and 100, and place each random number in a different element of a single-dimension array starting with the first number generated.

2.Locate the largest of the 10 numbers and display its value.

3.Display the array's contents in the order the numbers are initially inserted.This is called an unsorted list.

4.Using the bubble sort, now sort the array from smallest integer to the largest.The bubble sort must be in its own method; it cannot be in the main method.Here is the code for the bubble sort method. Use this code, and not some code you find online.

Bubble Sort Code:

public static void bubbleSort(int[] list)

{

int temp;

for (int i = list.length - 1; i > 0; i--)

{

for (int j = 0; j < i; j++)

{

if (list[j] > list[j + 1])

{

temp = list[j];

list[j] = list[j + 1];

list[j + 1] = temp;

}

}

}

}

5.Display the array's contents after the bubble sort is completed.

6.Add comments at the top of the class with your First and Last name, and comment the code to explain the various steps.

Step 3. Test your program.Below is an example of what the program output should look like.Your output will be different because the 10 random numbers will not be the same as the example.

Use the Snip It tool in Windows or a similar tool on the Mac to cut and paste the Eclipse Console output window into the same Word document as the algorithm in Step 1.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

How to write starter code for a Java mobile application?

Answered: 1 week ago