package 课堂测试1;
import java.util.Random;
public class 课堂测试1
{
public static void main(String args[])
{
int x,y,z,t;
System.out.println("四则运算题:");
for(int i=0;i<30;i++)
{
Random rand =new Random();
x=rand.nextInt(100);
Random rand1 =new Random();
y=rand1.nextInt(100);
Random rand2 =new Random();
z=rand2.nextInt(4);
switch(z)
{
case 0:
System.out.println(x+"+"+y+"=");
break;
case 1:
if(x<y)
{
t=x;
x=y;
y=t;
}
System.out.println(x+"-"+y+"=");
break;
case 2:
System.out.println(x+"*"+y+"=");
break;
case 3:
if(y!=0)
{
System.out.println(x+"/"+y+"=");
}
else
{
i=i-1;
}
break;
}
}
}
}
四则运算Java程序