68 329
Assignments Done
98,8%
Successfully Done
In November 2018

Answer to Question #58606 in Java | JSP | JSF for NOUR

Question #58606
Write a public static method that takes 3 integer numbers and return a string
that has the three numbers separated by a space and sorted in descending order.
Expert's answer
package test;


public class Sort {
public static void main(String[] args) {
System.out.println(sort(4, 3, 5));
}
public static String sort(int a, int b, int c) {
int tmp;
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
if (b < c) {
tmp = b;
b = c;
c = tmp;
}
if (a < b) {
tmp = a;
a = b;
b = tmp;
}
return a + " " + b + " " + c;
}
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions