CoreJava/exp1/Compare.java
2024-05-09 09:10:51 +08:00

31 lines
685 B
Java

package exp1;
//这段代码用于获取三个数据并输出其中的最大值
//编写于 2024.2.27
//Java核心技术(实验一)课堂任务
import java.util.Scanner;
public class Compare{
public static void main(String[] args)
{
Scanner scan =new Scanner(System.in);
System.out.print("请输入第一个数字: ");
int a = scan.nextInt();
System.out.print("请输入第二个数字: ");
int b = scan.nextInt();
System.out.print("请输入第三个数字: ");
int c = scan.nextInt();
scan.close();
int max = 0;
if(a>b && a>c) {max = a;}
else if(b>a && b>c) {max = b;}
else if(c>a && c>b) {max = c;}
System.out.println("最大数是:" + max);
}
}