输入任意正整数a,b,c,返回最大值
1.本文用到了java.util.Scanner包,利用Scanner in = new Scanner(System.in);实现界面输入数据
2.源代码如下:
package chapter1;
import java.util.Scanner;
public class one {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner in = new Scanner(System.in);
int a = 0, b = 0, c = 0;
System.out.print("请输入第一个数值:");
a = in.nextInt();
System.out.print("请输入第二个数值:");
b = in.nextInt();
System.out.print("请输入第三个数值:");
c = in.nextInt();
int max = a;
if (b > max)
max = b;
else if (c > max)
max = c;
System.out.print("最大值为:"+max);
}
}
3.运行结果: