package yun;
import java.util.Random;
import java.util.*;
public class number {
/**
* 作者:范铭祥
* 功能:一个简单的小学生四则运算生成系统
*/
public static void main(String[] args)
{
int max=4;
int min=1;
Random random = new Random();
//System.out.println(s);
boolean pan=true;
do
{
int s = random.nextInt(max)%(max-min+1) + min;
Scanner in=new Scanner (System.in);
System.out.println("请输入一个四则运算的第一个数:");
double x=in.nextDouble();
System.out.println("请输入一个四则运算的第二个数:");
double y=in.nextDouble();
switch(s)
{
case 1:
{
System.out.println(x+"+"+y+"=" );
double xy=in.nextDouble();
if(xy==x+y)
{
System.out.println("你做对了!!");
}
if(xy!=x+y)
{
System.out.println("你做错了!!");
}
break;
}
case 2:
{
System.out.println(x+"-"+y+"=" );
double xy=in.nextDouble();
if(xy==x-y)
{
System.out.println("你做对了!!");
}
if(xy!=x-y)
{
System.out.println("你做错了!!");
}
break;
}
case 3:
{
System.out.println(x+"*"+y+"=" );
double xy=in.nextDouble();
if(xy==x*y)
{
System.out.println("你做对了!!");
}
if(xy!=x*y)
{
System.out.println("你做错了!!");
}
break;
}
case 4:
{
System.out.println(x+"/"+y+"=" );
double xy=in.nextDouble();
if(xy==x/y)
{
System.out.println("你做对了!!");
}
if(xy!=x/y)
{
System.out.println("你做错了!!");
}
break;
}
}
}while(pan=true);
}
}