Computer Science, asked by aditisingh12468, 8 months ago

Write a java program to enter 3 numbers and print then in descending order.



Answers

Answered by geethagov1959
1

Answer

Scanner reader = new Scanner(System.in);  // Reading from System.in

System.out.println("Enter a number: ");

int n = reader.nextInt(); // Scans the next token of the input as an int.

From Fastest way to sort 3 values in Java:

if (a > b)

  swap(a,b)

if (b > c)

  swap(b,c)

if (a > b)

  swap(a,b)

print a,b,c

All I did was use Google to search for “java input” and “java sort 3 numbers” and take the first result from Stack Overflow - Where Developers Learn, Share, & Build Careers

I believe you can do the same to join the pieces and complete the code.

Similar questions
Science, 4 months ago