import java.util.Scanner;
class heimaGame{
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
boolean flat = true;
abc:while(flat){
System.out.println("欢迎来到黑马游戏厅");
System.out.println("有一下游戏可以供你选择");
System.out.println("1:倒序");
System.out.println("2:输入两个数之间的偶数和");
System.out.println("3:小星星");
System.out.println("4:一个大大的惊喜");
System.out.println("5:退出游戏界面");
int num = sc.nextInt();
switch(num){
case 1:
System.out.println("请重新输入第一个数字");
int a = sc.nextInt();
System.out.println("请重新输入第二个数字");
int b = sc.nextInt();
System.out.print("他们的倒序为:");
sequence(a,b);
break;
case 2:
boolean ff = true;
while(ff){
System.out.println("请重新输入第一个数字");
int c = sc.nextInt();
System.out.println("请重新输入第二个数字");
int d = sc.nextInt();
if(c>d){
System.out.println("输入不正确,请重新输入");
}else{
int sun = add(c,d);
System.out.println(c+"到"+d+"之间偶数和为"+sun);
ff = false;
}
}
break;
case 3:
System.out.println("来个数吧");
int e = sc.nextInt();
star(e);
break;
case 4:
System.out.println("重温下小学的数学吧");
table();
break;
case 5:
flat = false;
break;
default:
System.out.println("你个逗比,请重新输入");
break;
}
}
}
public static void table(){
for(int i = 1;i<=9;i++){
for(int j = 1;j<=i;j++){
System.out.print(j+"*"+i+"="+j*i+"");
}
System.out.println();
}
System.out.println("===========================================================");
for(int i = 9;i>=1;i--){
for(int j = 1;j<=i;j++){
System.out.print(j+"*"+i+"="+j*i+"");
}
System.out.println();
}
}
public static void star(int a){
for(int i = 0;i<a;i++){
for(int j = 0; j<a;j++){
System.out.print("*");
}
System.out.println();
}
}
/*
键盘收入两个数,比较大小,然后循环求和
*/
public static int add(int a,int b){
int sum = 0;
for(int i = a;i<=b;i++){
if(i%2==0){
sum+=i;
}
}
return sum;
}
public static void sequence(int a,int b){ //sequence 顺序
a = a^b;
b = a^b;
a = a^b;
System.out.println(a+"========"+b);
}
}
|
|