Skip to content

Commit 37209ea

Browse files
committed
day05
1 parent 83f43e8 commit 37209ea

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed

practice/test/src/day05/getmax.java

+21
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
package day05;
2+
import java.util.Scanner;
3+
// 方法不能嵌套定义
4+
// void表示无返回值,可以省略return,也可以单独的书写return,后面不加数据
5+
6+
public class getmax {
7+
public static void main(String[] args) {
8+
Scanner sc = new Scanner(System.in);
9+
System.out.print("请输入第一个数:");
10+
double a = sc.nextDouble();
11+
System.out.print("请输入第二个数:");
12+
double b = sc.nextDouble();
13+
//double c = getmax0(a, b);
14+
System.out.println(a + "和" + b + "中最大的数是:" + getmax0(a, b));
15+
sc.close();
16+
}
17+
public static double getmax0(double a, double b) {
18+
double c = a > b ? a : b;
19+
return c;
20+
}
21+
}

0 commit comments

Comments
 (0)