• 博客园logo
  • 会员
  • 众包
  • 新闻
  • 博问
  • 闪存
  • 赞助商
  • HarmonyOS
  • Chat2DB
    • 搜索
      所有博客
    • 搜索
      当前博客
  • 写随笔 我的博客 短消息 简洁模式
    用户头像
    我的博客 我的园子 账号设置 会员中心 简洁模式 ... 退出登录
    注册 登录
浅夏〆雪ら忆汐
博客园    首页    新随笔    联系   管理    订阅  订阅

四则运算

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

namespace 四则运算
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
        public static  int right = 0;//正确的题目个数
        public static int mistake =0;//错误的题目个数
        //随机产生的随机数0-10
        private void RandomNum()
        {
            Random ran = new Random();
            int n1, n2;
            n1 = ran.Next(0, 11);
            n2 = ran.Next(0, 11);
            textBox1.Text = n1.ToString();
            textBox2.Text = n2.ToString();
            textBox3.Text = "";
            
        }       
        public static int sum;
        //调换四则运算的方法
        private void comboBox1_SelectedIndexChanged(object sender, EventArgs e)
        {
            
            textBox3.Focus();
            string str = comboBox1.SelectedItem.ToString(); 
            RandomNum();
            switch (str)
            {
                case "+":
                    sum = int.Parse(textBox1.Text) + int.Parse(textBox2.Text);
                    break;
                case "-":
                    sum = int.Parse(textBox1.Text) - int.Parse(textBox2.Text);
                    break;
                case "*":
                    sum = int.Parse(textBox1.Text) * int.Parse(textBox2.Text);
                    break;
                case "/":
                    sum = int.Parse(textBox1.Text) / int.Parse(textBox2.Text);
                    break;
            } 
           
        }
        
        //题目的正确个数的题目的错误个数
        private void button3_Click(object sender, EventArgs e)
        {
            textBox3.Focus();
            RandomNum();
            if(textBox3.Text == sum.ToString())
            {
                right++;
                RandomNum();
            }
            else
            {
                mistake++;
                RandomNum();
            }
            
        }
        private void button1_Click(object sender, EventArgs e)
        {
            textBox4.Text = right.ToString();
            textBox5.Text = mistake.ToString() ;
        }
    }
}
求助:助教你帮我看看我的代码哪里出错了,我感觉我的思路是对的啊,但是最后正确的题数和错误的题数结果不正确。
Psp分析:
psp Personal Software Process Stages Time
planning 计划       15(m)
Estimate 估计这个任务需要多长时间       1(h)
Development 开发       2(h)
Analysis 需求分析       30(m)
Design Review 设计复审       40(m)
Design 具体设计       20(m)
Code review 代码复审       10(m)
Coding 具体编码       30(m)
Test 测试       1(m)

  

posted @ 2015-10-01 02:55  浅夏〆雪ら忆汐  阅读(195)  评论(2)    收藏  举报
刷新页面返回顶部
博客园  ©  2004-2025
浙公网安备 33010602011771号 浙ICP备2021040463号-3