import java.util.Scanner;
class Choose
{
public static void main(String[] args)
{
w:while(true){
System.out.println("请照应输入:");
System.out.println("\t1.打印九九乘法表");
System.out.println("\t2.获取三个数中的最大值");
System.out.println("\t3.获取三个数中的最小值");
System.out.println("\t4.得到三个数的和");
//System.out.println("\t5.打印图形");
//System.out.println("\t6.计算器");
System.out.println("\t5.退出");
int i ;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入选择:");
i = scanner.nextInt();
switch (i)
{
case 1:
System.out.println("九九乘法表打印如下:");
jiuJiu();
break ;
case 2:
System.out.println("最大值为:" + getMax());
break ;
case 3:
System.out.println("最小值为:" + getMin());
break ;
case 4:
System.out.println("三个数的和为:" + getSum());
break ;
case 5:
break w;
default :
System.out.println("输入有误:没有此选项!!");
break ;
}
}
}
public static void jiuJiu()
{
for (int i = 1; i <= 9; i++)
{
for (int j = 1; j <= i; j++)
{
System.out.print(j + " * " + i + " = " + i*j + "\t");
}
System.out.println();
}
}
public static int getSum()
{
int a, b, c;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入三个数:");
a = scanner.nextInt();
b = scanner.nextInt();
c = scanner.nextInt();
return a + b + c;
}
public static int getMax()
{
int a, b, c;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入三个数:");
a = scanner.nextInt();
b = scanner.nextInt();
c = scanner.nextInt();
if (a > b)
{
if (a > c)
{
return a;
}else
{
return c;
}
}else if (b > c)
{
return b;
}else
{
return c;
}
}
public static int getMin()
{
int a, b, c;
Scanner scanner = new Scanner(System.in);
System.out.println("请输入三个数:");
a = scanner.nextInt();
b = scanner.nextInt();
c = scanner.nextInt();
if (a < b)
{
if (a < c)
{
return a;
}else
{
return c;
}
}else if (b < c)
{
return b;
}else
{
return c;
}
}
}作者: 一城一世界 时间: 2015-7-26 07:08
徐朋威0716 发表于 2015-7-26 01:52
import java.util.Scanner;
class Choose
{