This is a question about java,I need some help!Write a program that asks the user for three floating point (decimal) numbers and prints the three numbers in sorted order.For example:Please enter three numbers:492.5The numbers in sorted order are2.549wo cong lai mei zuo guo a ,bu zhi dao zm zuo a ,wo ye bu xiang da yingwen ke shi zhe dian nao mei zhong wen de shu ru fa ,qiu bang zu
This is a question about java,I need some help!
Write a program that asks the user for three floating point (decimal) numbers and prints the three numbers in sorted order.For example:
Please enter three numbers:
4
9
2.5
The numbers in sorted order are
2.5
4
9
wo cong lai mei zuo guo a ,bu zhi dao zm zuo a ,wo ye bu xiang da yingwen ke shi zhe dian nao mei zhong wen de shu ru fa ,qiu bang zu
这问题确实不难,多看看书上的
import java.util.Arrays;
import java.util.Scanner;
public class Test {
public static void main(String[] args) {
int i = 3;
int[] list = new int[3];
System.out.println("please Please enter three numbers:");
for (int j = 0; j Scanner sc = new Scanner(System.in);
String t = sc.next();
list[j] = Integer.parseInt(t);
}
Arrays.sort(list);
System.out.println("The numbers in sorted order are:");
for (int k :list) {
System.out.println(k);
}
}
}