四则运算最终成品

组员:刘伟 李晨(http://www.cnblogs.com/jiajun1/)

1.设计思路

这次采用的C#制作的图形化的四则运算程序。

2.源代码

  1 using System;
  2 using System.Collections.Generic;
  3 using System.ComponentModel;
  4 using System.Data;
  5 using System.Drawing;
  6 using System.Linq;
  7 using System.Text;
  8 using System.Threading.Tasks;
  9 using System.Windows.Forms;
 10 
 11 namespace 四则运算2._0
 12 {
 13     public partial class Form1 : Form
 14     {
 15         int shumu = 0;
 16         int min = 0;
 17         int max = 0;
 18         string allfuhao;
 19         string fuhao;
 20         public Form1()
 21         {
 22             InitializeComponent();
 23         }
 24         private void Form1_Load(object sender, EventArgs e)
 25         {
 26             richTextBox1.Clear();
 27             textBox2.Clear();
 28             textBox3.Clear();
 29             textBox4.Clear();
 30         }
 31         private void checkBox2_CheckedChanged(object sender, EventArgs e)
 32         {
 33 
 34         }
 35 
 36         private void richTextBox1_TextChanged(object sender, EventArgs e)
 37         {
 38 
 39         }
 40 
 41         private void textBox4_TextChanged(object sender, EventArgs e)
 42         {
 43 
 44         }
 45 
 46         private void label2_Click(object sender, EventArgs e)
 47         {
 48 
 49         }
 50 
 51         private void button2_Click(object sender, EventArgs e)
 52         {
 53             shumu = int.Parse(textBox3.Text);
 54             min = int.Parse(textBox4.Text);
 55             max = int.Parse(textBox2.Text);
 56             System.Random number = new Random(System.DateTime.Now.Millisecond);
 57             //循环输出题目
 58             for (int i = 0; i <shumu; i++)
 59             {
 60                 int num1 = number.Next(min, max);
 61                 int num2 = number.Next(min, max);
 62                 int num3 = number.Next(min, max);
 63                 int yunsuan1 = number.Next(0, 4);
 64                 int yunsuan2 = number.Next(0, 2);
 65                 //定义变量
 66                 int fuhaonum = number.Next(0, 2);
 67                 if (fuhaonum == 0)//符号进行随机
 68                 {
 69                     fuhao = "+";
 70                 };
 71                 if (fuhaonum == 1)
 72                 {
 73                     fuhao = "-";
 74                 };
 75                 int allfuhaonum = number.Next(0, 4);
 76                 if (allfuhaonum == 0)
 77                 {
 78                     allfuhao = "+";
 79                 };
 80                 if (allfuhaonum == 1)
 81                 {
 82                     allfuhao = "-";
 83                 };
 84                 if (allfuhaonum == 2)
 85                 {
 86                     allfuhao = "*";
 87                 };
 88                 if (allfuhaonum == 3)
 89                 {
 90                     allfuhao = "/";
 91                 };
 92 
 93                 if (checkBox4.Checked == true)//有括号
 94                 {
 95                     richTextBox1.Text += num3;
 96                     if (checkBox1.Checked == true)//有乘除
 97                     {
 98                         if (checkBox3.Checked == true)//结果允许为负
 99                         {
100                             if (yunsuan1 == 0) { richTextBox1.Text += allfuhao + "(" + num1 + "+" + num2 + ")" + "="+"     "; }
101                             else if (yunsuan1 == 1) { richTextBox1.Text += allfuhao + "(" + num1 + "*" + num2 + ")" + "=" + "     "; }
102                             else if (yunsuan1 == 2) { richTextBox1.Text += allfuhao + "(" + num1 + "-" + num2 + ")" + "=" + "     "; }//减法有负数
103                             else if (yunsuan1 == 3 && num2 != 0) { richTextBox1.Text += allfuhao + "(" + num1 + "/" + num2 + ")" + "=" + "     "; }//除法有余数
104                         }
105                         else if(checkBox3.Checked == false)//结果不允许为负
106                         {
107                             if (yunsuan1 == 0) { richTextBox1.Text += allfuhao + "(" + num1 + "+" + num2 + ")" + "=" + "     "; }
108                             else if (yunsuan1 == 1) { richTextBox1.Text += allfuhao + "(" + num1 + "*" + num2 + ")" + "=" + "     "; }
109                             else if (yunsuan1 == 2 && num1 > num2) { richTextBox1.Text += allfuhao + "(" + num1 + "-" + num2 + ")" + "=" + "     "; }//减法无负数
110                             else if (yunsuan1 == 2 && num1 < num2) { richTextBox1.Text += allfuhao + "(" + num2 + "-" + num1 + ")" + "=" + "     "; }//减法无负数
111                             else if (yunsuan1 == 3 && num2 != 0) { richTextBox1.Text += allfuhao + "(" + num1 + "/" + num2 + ")" + "=" + "     "; }//除法有余数
112                         }
113                     }
114                     else if(checkBox1.Checked == false)//没有乘除法
115                         if (checkBox3.Checked == true)//减法有负数
116                         {
117                             if (yunsuan2 == 0) { richTextBox1.Text += fuhao + "(" + num1 + "+" + num2 + ")" + "=" + "     "; }
118                             else if (yunsuan2 == 1) { richTextBox1.Text += fuhao + "(" + num1 + "-" + num2 + ")" + "=" + "     "; }//减法有负数
119                         }
120                         else if (checkBox3.Checked == false)//结果不允许为负
121                         {
122                             if (yunsuan2 == 0) { richTextBox1.Text += fuhao + "(" + num1 + "+" + num2 + ")" + "=" + "     "; }
123                             else if (yunsuan2 == 1 && num1 > num2) { richTextBox1.Text += fuhao + "(" + num1 + "-" + num2 + ")" + "=" + "     "; }//减法无负数
124                             else if (yunsuan2 == 1 && num1 <= num2) { richTextBox1.Text += fuhao + "(" + num2 + "-" + num1 + ")" + "=" + "     "; }//减法无负数
125                         }
126                 }
127                 else if (checkBox4.Checked == false)//没有括号
128                 {                
129                     if (checkBox1.Checked == true)//有乘除
130                     {
131                         if (checkBox3.Checked == true)//结果允许为负
132                         {
133                             if (yunsuan1 == 0) { richTextBox1.Text += num1 + "+" + num2 + "=" + "     "; }
134                             else if (yunsuan1 == 1) { richTextBox1.Text += num1 + "*" + num2 + "=" + "     "; }
135                             else if (yunsuan1 == 2) { richTextBox1.Text += num1 + "-" + num2 + "=" + "     "; }//减法有负数
136                             else if (yunsuan1 == 3 && num2 != 0) { richTextBox1.Text += num1 + "/" + num2 + "=" + "     "; }//除法有余数
137                         }
138                         else if (checkBox3.Checked == false)//结果不允许为负
139                         {
140                             if (yunsuan1 == 0) { richTextBox1.Text += num1 + "+" + num2 + "=" + "     "; }
141                             else if (yunsuan1 == 1) { richTextBox1.Text += num1 + "*" + num2 + "=" + "     "; }
142                             else if (yunsuan1 == 2 && num1 > num2) { richTextBox1.Text += num1 + "-" + num2 + "=" + "     "; }//减法无负数
143                             else if (yunsuan1 == 2 && num1 <= num2) { richTextBox1.Text += num2 + "-" + num1 + "=" + "     "; }//减法无负数
144                             else if (yunsuan1 == 3 && num2 != 0) { richTextBox1.Text += num1 + "/" + num2 + "=" + "     "; }//除法有余数
145                         }
146                     }
147                     else if (checkBox1.Checked == false)//没有乘除法
148                          if (checkBox3.Checked == true)//结果允许为负
149                         {
150                             if (yunsuan2 == 0) { richTextBox1.Text += num1 + "+" + num2 + "=" + "     "; }
151                             else if (yunsuan2 == 1) { richTextBox1.Text += num1 + "-" + num2 + "=" + "     "; }//减法有负数                          
152                         }
153                          else if (checkBox3.Checked == false)//结果不允许为负
154                          {
155                              if (yunsuan2 == 0) { richTextBox1.Text += num1 + "+" + num2 + "=" + "     "; }
156                              else if (yunsuan2 == 1 && num1 > num2) { richTextBox1.Text += num1 + "-" + num2 + "=" + "     "; }//减法无负数
157                              else if (yunsuan2 == 1 && num1 <= num2) { richTextBox1.Text += num2 + "-" + num1 + "=" + "     "; }//减法无负数
158                          }
159                 }
160             }
161 
162         }
163 
164         private void button1_Click(object sender, EventArgs e)
165         {
166             richTextBox1.Clear();
167             textBox4.Text = "";
168             textBox3.Text = "";
169             textBox2.Text = "";
170             checkBox1.Checked = false;
171             checkBox2.Checked = false;
172             checkBox3.Checked = false;
173             checkBox4.Checked = false;
174         }
175 
176         private void textBox2_TextChanged(object sender, EventArgs e)
177         {
178 
179         }
180 
181         private void textBox3_TextChanged(object sender, EventArgs e)
182         {
183 
184         }
185 
186         private void groupBox1_Enter(object sender, EventArgs e)
187         {
188 
189         }
190 
191         private void checkBox1_CheckedChanged(object sender, EventArgs e)
192         {
193 
194         }
195 
196         private void checkBox4_CheckedChanged(object sender, EventArgs e)
197         {
198 
199         }
200 
201         private void fileSystemWatcher1_Changed(object sender, System.IO.FileSystemEventArgs e)
202         {
203 
204         }
205 
206         private void checkBox3_CheckedChanged(object sender, EventArgs e)
207         {
208 
209         }
210 
211         private void button3_Click(object sender, EventArgs e)
212         {            
213             textBox4.Text = "";
214             textBox3.Text = "";
215             textBox2.Text = "";           
216         }
217 
218         private void button4_Click(object sender, EventArgs e)
219         {
220             checkBox1.Checked = false;
221             checkBox2.Checked = false;
222             checkBox3.Checked = false;
223             checkBox4.Checked = false;
224         }
225     }
226 }

3.结果截图

4项目计划总结:

 

 

日期&&任务听课编写程序阅读相关书籍网上查找资料日总计
周一10070 15195
周二 4045 95
周三 504535120
周四1004040 180
周五 90 15105
周六  401565
周日  45 45
周总

 

 

 

 

 

 

 

 

 

5时间记录日志:

 

 

日期开始时间结束时间中断时间净时间活动备注
3/2714:0015:5010100听课软件工程上课
 21:0021:25 20阅读书籍 《构建之法》
3/2814:0017:0010110编程编写作业
 18:0022:0010110看书《构建之法》
3/2921:0021:30 30编程编写老师布置的作业
3/3014:0015:5010100听课软件工程上课
3/3116:0018:00 120编程编写作业
4/49:009:30 30看书《构建之法》 《人月神话》
4/59:009:30 30看书《构建之法》

 

 

 

 

 

 

 

 

 

6缺陷记录日志:

 

日期编号类型引入阶段排除阶段修复时间修复缺陷
3月26日1 编码编码30min 

 

在c#的运用中出现了一些知识问题查阅资料解决

转载于:https://www.cnblogs.com/Lw-1573/p/5360910.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值