码迷,mamicode.com
首页 > 其他好文 > 详细

第二次作业——四则运算

时间:2015-10-06 23:37:51      阅读:215      评论:0      收藏:0      [点我收藏+]

标签:

package sz;

import java.awt.Button;
import java.awt.Frame;
import java.awt.Label;
import java.awt.TextField;
import java.util.Random;

public class Jsq
{
	     Frame frame = new Frame("四则运算");
	     frame.setVisible(true);
		 String one="";
		 String second="";
		 String[] str=new String[10];
		 String[] stb=new String[10];
	     public String tiMu()
		 {
			 char[] ch = new char[] { ‘+‘, ‘-‘, ‘*‘, ‘/‘ };
			 int a;
		     int b;
		     char c;
			 Random r = new Random();
			 boolean suiji = true;
			 while (suiji) 
			  {
			    a = r.nextInt(11);
			    b = r.nextInt(11);
			    c = ch[r.nextInt(ch.length)];
	          }
	     final TextField one = new TextField(10);
	     final TextField second = new TextField(10);
	     Label label = new Label("=");
		 final TextField three = new TextField(10);
		 Button button = new Button("计算");
		 }
		 public void tiShi()
		 {
			   for(int i=0;i<10;i++)
			   {
			   tiMu();
			   str[i]=one;
			   stb[i]=second;
			   one="";
			   second="";
			   for(int j=0;j<i;j++)
			     {
			        if(str[j]==str[i]||str[j]==stb[i]
			     }
			   System.out.println("第"+(i+1)+"题:"+str[i]);
			   }
		}
			 
		public static void main(String[] args) 
		 {
			  Jsq js=new Jsq();
			  js.tiShi();
	     }
}

总结:实践出真知,第一次自己研究代码,参考了网上的资料,有些代码看不懂,暂时就写这样吧,下次会继续研究下,把代码完善,希望老师不要介意。谢谢老师!

  

第二次作业——四则运算

标签:

原文地址:http://www.cnblogs.com/wen2020/p/4857971.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!