using System;
using System.Collections.Generic;
using
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
Random radnom = new Random();
textBox1.Text = radnom.Next(101).ToString();
textBox3.Text = radnom.Next(101).ToString();
decimal result;
switch (radnom.Next(4).ToString())
{
case "0":
textBox2.Text = "加";
result = Decimal.Round((Decimal.Parse(textBox1.Text.ToString()) + Decimal.Parse(textBox3.Text.ToString())),4);
textBox4.Text =result.ToString();
break ;
case "1":
textBox2.Text = "减";
result = Decimal.Round((Decimal.Parse(textBox1.Text.ToString()) -Decimal.Parse(textBox3.Text.ToString())), 4);
textBox4.Text = result.ToString();
break;
case "2":
textBox2.Text = "乘";
result = Decimal.Round((Decimal.Parse(textBox1.Text.ToString()) *Decimal.Parse(textBox3.Text.ToString())), 4);
textBox4.Text = result.ToString();
break;
case "3":
textBox2.Text = "除";
result = Decimal.Round((Decimal.Parse(textBox1.Text.ToString()) /Decimal.Parse(textBox3.Text.ToString())), 4);
textBox4.Text = result.ToString();
break;
default :
break ;
}
}
}
}