import java.util.*;
class Demo7
{
public static void main(String[] args)
{
chengfa();
}
public static void chengfa()
{
Random ran=new Random();
Scanner sc=new Scanner(System.in);
//System.out.print("请输入两个一位的正整数");
int a=ran.nextInt(10);
int b=ran.nextInt(10);
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("第一题");
System.out.println("How much is 6 times 7 ?");
int x=sc.nextInt();
while (true)
{
if (x==42)
{
System.out.println("very good!");
break;
}
else {
System.out.println("no,please try again.");
System.out.println("请思考以后,重新输入");
x=sc.nextInt();
}
}
System.out.println("第二题");
System.out.println("How much is "+a+" times "+b+" ?");
int s=sc.nextInt();
while (true)
{
if (s==a*b)
{
System.out.println("very good!");
break;
}
else {
System.out.println("no,please try again.");
System.out.println("请思考以后,重新输入");
s=sc.nextInt();
}
}
a=ran.nextInt(10);
b=ran.nextInt(10);
System.out.println("a="+a);
System.out.println("b="+b);
System.out.println("第三题");
System.out.println("How much is "+a+" times "+b+" ?");
s=sc.nextInt();
while (true)
{
if (s==a*b)
{
System.out.println("very good!");
break;
}
else {
System.out.println("no,please try again.");
System.out.println("请思考以后,重新输入");
s=sc.nextInt();
}
}
}
}
|