Java: Accepts six numbers as input and sorts them in descending order
Sort Six Numbers in Descending Order
Write a Java program that accepts six numbers as input and sorts them in descending order.
Input:
Input consists of six numbers n1, n2, n3, n4, n5, n6 (-100000 ≤ n1, n2, n3, n4, n5, n6 ≤ 100000). The six numbers are separated by a space.
Visual Presentation:
Sample Solution:
Java Code:
Sample Output:
Input six integers: 4 6 8 2 7 9 After sorting the said integers: 9 8 7 6 4 2
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to sort six numbers in ascending order using a recursive sorting algorithm.
- Write a Java program to sort six numbers in descending order without using any built-in sorting functions.
- Write a Java program to sort six numbers in descending order and then reverse the sorted list.
- Write a Java program to sort six numbers in descending order using bubble sort while counting the number of swaps.
Java Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a Java program to compute and print sum of two given integers (more than or equal to zero). If given integers or the sum have more than 80 digits, print "overflow".
Next: Write a Java program to test whether two lines PQ and RS are parallel. The four points are P(x1, y1), Q(x2, y2), R(x3, y3), S(x4, y4).
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.