四则运算

源程序:

public class yunsuan

{

/**
* @param args
*/
public static void main(String[] args)
{
// TODO Auto-generated method stub

System.out.println("请计算下列各题:");
for(int i=1;i<=30;i++)
{
int A=(int)(Math.random()*99);
int B=(int)(Math.random()*99);
int j=(int)(Math.random()*4);
if(j==1)
System.out.println(A+"+"+B+"=");
if(j==2)
System.out.println(A+"-"+B+"=");
if(j==3)
System.out.println(A+"*"+B+"=");
if(j==4)
System.out.println(A+"/"+B+"=");
}

}

private static int rand()
{
// TODO Auto-generated method stub
return 0;
}

}

结果截图:

  在课上刚提出要编写这一程序时,一开始没有找到编程的思路,导致没有想法的编写,不知如何下手,后来听了同学的讲解,看了她的思路,脑袋里有了一些想法,最终写了出来。所以,以后再写程序时一定要先想好思路才能顺利的完成,要多思考。

原文地址:https://www.cnblogs.com/mxj333/p/4319088.html