Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

import java.util.Random; import java.util.Arrays; public class Exercise3_01 { public static void main(String[] args) { Random r = new Random(); int arr[] = new int[200]; for(int

import java.util.Random;

import java.util.Arrays;

public class Exercise3_01

{

public static void main(String[] args)

{

Random r = new Random();

int arr[] = new int[200];

for(int i=0;i

{

arr[i] = r.nextInt(1000001);

}

System.out.println("Before sorting");

System.out.println();

for(int i=0;i

{

System.out.format("%10d",arr[i]);

if((i+1)%4==0)

{

System.out.println();

}

}

for(int i=0;i

{

int min = i;

for(int j=i+1;j

{

if(arr[j]

{

min = j;

}

}

int t = arr[i];

arr[i] = arr[min];

arr[min] = t;

}

System.out.println();

System.out.println("After sorting Ascending");

System.out.println();

for(int i=0;i

{

System.out.format("%10d",arr[i]);

if((i+1)%4==0)

{

System.out.println();

}

}

}

}

I need to also sort the numbers by descending order how do I implement that.

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

Visual Basic6 Database Programming

Authors: John W. Fronckowiak, David J. Helda

1st Edition

0764532545, 978-0764532542

More Books

Students also viewed these Databases questions

Question

Explain how to build high-performance service delivery teams.

Answered: 1 week ago

Question

Understand what a service-oriented culture is.

Answered: 1 week ago