import java.util.Scanner;
class Demo1
{
public static void Os()
{
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
System.out.println("您输入的是"+i);
for (int j = 0;j < i ; j += 2 )
{
System.out.print(j + " ");
}
}
public static void printStar()
{
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
System.out.println("您输入的是"+i);
for (int x = 1;x <= i ; x++ )
{
for (int y = 1 ; y <= x ; y++ )
{
System.out.print("*");
}
System.out.println();
}
}
public static void jiuJiu()
{
for (int x = 1;x <= 9 ; x++ )
{
for (int y = 1 ; y <= x ; y++ )
{
System.out.print(y+"*"+x+"="+x*y+'\t');
}
System.out.println();
}
}
public static void sXH()
{
System.out.println("水仙花数!");
for (int i = 101; i<1000 ; i++ )
{
int b = i / 100;
int s = i % 100 / 10;
int g = i % 100 % 10;
//System.out.println("b="+b +"s="+ s +"g="+g);
if (b*b*b+s*s*s+g*g*g == i)
{
System.out.println(i + " ");
}
}
}
public static void main(String[] args)
{
boolean flag = true;
int count = 1;
while (flag)
{
System.out.println("请输入用户名:");
Scanner sc = new Scanner(System.in);
String name=sc.nextLine();
System.out.println("请输入密码:");
// Scanner sc = new Scanner(System.in);
String pass=sc.nextLine();
String username = "liuzhen";
String password = "123456";
if (username.equals(name)&& password.equals(pass))
{
flag = false;
System.out.println("欢迎来到黑马游戏大厅");
}
else
{
if (count == 5)
{
System.out.println("您的输入次数已经使用完毕!!将退出程序!!");
flag = false;
}
else{
System.out.println("用户名或者密码错误,请重新输入! 您还有"+(5-count)+"次机会");
count++;
}
}
}
boolean f = true;
while (f)
{ System.out.println("亲!请输入序号,选择您要玩的游戏!");
System.out.println("1 请输入整数N,求0-N个数之间的偶数");
System.out.println("2 请输入一个1到10的整数n,给您打印一个n行的三角形的小星星");
System.out.println("3 亲 送您一个惊喜呦!!");
System.out.println("4 让您重返童趣");
System.out.println("5 退出程序!");
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
switch (i)
{
case 1:
System.out.println("您选择的是序号 1 请输入整数N,求0-N个数之间的偶数");
Demo1.Os();
break;
case 2:
System.out.println("您选择的是序号 2 请输入一个1到10的整数n,给您打印一个n行的三角形的小星星");
printStar();
break;
case 3:
System.out.println("您选择的是序号 3 亲 送您一个惊喜呦!!");
sXH();
break;
case 4:
System.out.println("您选择的是序号 4 让您重返童趣 ");
jiuJiu();
break;
case 5:
f = false ;
break;
default:
System.out.println("请您按照提示操作!");
}
}
}
}
|
|