The ascending order was displaying the same as descending order. how do i get the ascending order to be different from descending order?

public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n =10;
int a[] = new int[n];
System.out.println("Enter all the elements:");
for (int i = 0; i < n; i++){
a[i] = in.nextInt();
}

for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (a[i] < a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("Descending Order:");
for (int i = 0; i < n; i++){
System.out.print(a[i]+",");
}

for (int i = 0; i < n; i++){
for (int j = i + 1; j < n; j++){
if (a[i] > a[j]) {
int temp = a[i];
a[i] = a[j];
a[j] = temp;
}
}
}
System.out.println("\nAscending Order:");
for (int i = 0; i < n; i++){
System.out.print(a[i]+",");
}
}

1. 👍 1
2. 👎 0
3. 👁 72
1. Which one is wrong and which one is right? This will help us focus on only the relevant code.

1. 👍 0
2. 👎 0
2. the ascending order is the same as descending order.

1. 👍 0
2. 👎 0

## Similar Questions

1. ### computer

The main purpose of the Sort feature of Excel is to_________. reorder data alphabetically in ascending or descending order change the data order in one column, then the one next to it arrange data into specific subgroups reorder

asked by Bri on April 30, 2018
2. ### Math

Find the difference of all the prime numbers between10 and25 arranged in descending and ascending order.Give your answer in words.

asked by Benjamin on August 9, 2011
3. ### calculus

f(x)= x^3/x^2-16 defined on the interval [-19,16]. Enter points, such as inflection points in ascending order, i.e. smallest x values first. Enter intervals in ascending order also. What are F(x) TWO vertical asympototes? F(x)is

asked by mkcolema on March 17, 2009

f(x) = \frac{ x^3 }{ x^2 - 25 } defined on the interval [ -18, 18 ]. Enter points, such as inflection points in ascending order, i.e. smallest x values first. Enter intervals in ascending order also. The function f(x) has vertical

asked by Anonymous on November 4, 2014
5. ### math

Name: Barbara Dillon Date: July 18 2010 1. Divide 90รท18 =5 Answer is 5 2. Place the following set of numbers in ascending order. 22, โ7, 8, โ4, 12, โ1, 14 Ascending order : -7, -4, -1, 8, 14, 22 3. Add 4. Subtract 5. Divide

asked by barbara on July 18, 2010
6. ### Geomerty

Place the following set of numbers in ascending order -2/9,5/9,1/8,-1/9,3/7 Would the correct order be 1/8,2/9,1/8,3/7,5/9

asked by Jerome on July 2, 2010
7. ### math

A number m is formed by writing all the prime numbers between 0 and 10 in an ascending order. Another number n is formed by writing all the square numbers between 0 and 10 in a descending order. (a) Find m - n; (b) Express (m - n)

asked by kd on October 31, 2018
8. ### math

what is the answer when you order the common fraction 4/7,1/2 and 2/9 in ascending order?????????????????????????

asked by ashley on January 17, 2016
9. ### Algebra

A 5 digit positive integer is a "mountain number" if the first 3 digits are in ascending order and the last 3 digits are in descending order. For example, 35 761 is a mountain number, but 32 323 and 35 655 are not. How many 5

asked by Jack on April 2, 2011
10. ### Math

What is 4,-6,0,8,-9 in ascending order

asked by Uggg on September 15, 2016

More Similar Questions