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.549

来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/19 04:55:03
Thisisaquestionaboutjava,Ineedsomehelp!Writeaprogramthataskstheuserforthreefloatingpoint(decimal)num

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.549
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

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.549
这问题确实不难,多看看书上的
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 < i; 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);
}
}
}