/**
*
* @author Zhangtingfei
*/
//package 张庭飞;
import java.util.Random;
import org.junit.Test;
public class Sizeyunsuan {
public static void main(String[] args) {
calculate(20);
}
/*
* 随机生成题函数,参数amount为出题数量
*/
@Test
public static void calculate(int amount)
{
Random r = new Random();
for(int x=0;x<amount;x++)
{
int symbol = r.nextInt(4);
int front = r.nextInt(100);
int last = r.nextInt(100);
char sym =‘+‘;
switch(symbol)
{
case 0:sym=‘-‘;break;
case 1:sym=‘x‘;break;
case 2:sym=‘/‘;break;
case 3:break;
}
if(front>=last)
{
System.out.println(front+""+sym+last);
}
else
{
System.out.println(last+""+sym+front);
}
}
}
}
原文:http://www.cnblogs.com/zhangtingfei/p/5296110.html