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
人气:208 ℃ 时间:2020-02-03 15:49:15
解答
这问题确实不难,多看看书上的
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);
}
}
}
推荐
- 数学里的Residue integration method是什么意思
- Falling in love three times is perfect in life-Once ignorant,once impressive,once for lifetime.的翻译是什么?
- 已知F1 F2是椭圆x²/a²+y²/b²=1(a>b>0)的左右焦点,A是椭圆上位于第一象限内的
- 初中化学晶体硫酸钠和氯化钠
- 编写一个C#控制台应用程序,根据半径,计算圆的周长和面积.半径r,周长circle,面积area,π为3.14 求步骤
- 探究水和无机盐在茎中运输的部位,用的是对照实验的方法,其单一变量是什么
- 如图,四边形ABCD中,∠ABC=120°,AB⊥AD,BC⊥CD,AB=4,CD=53,则该四边形的面积是_.
- 5+7乘8+12除4-2=20,括号应该加哪里才能让等式成立,答对了后给高分、
猜你喜欢