C#实现四则计算器及三角函数求值-软件设计规范

本文介绍了一个使用C#编写的四则运算及三角函数计算器,包括加减乘除、乘方、正弦、余弦和正切功能。程序通过TextBox输入数字和运算符,能够处理除零情况,但存在某些特定三角函数计算结果错误的问题。
摘要由CSDN通过智能技术生成
实验名称
C#实现四则计算器
需求:实现加减乘除四则计算,除零结果为零。
给出设计思路与实现代码。
提交代码与设计文档。

2.实验内容
2)源程序
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;


namespace WindowsFormsApplication1
{
    public partial class Form1 : Form
    {
        private int s;//运算符的标识符
        private double x, y;//运算数
        private string num;   //进行计算的数字
        public Form1()
        {
            InitializeComponent();
        }
        public void Form1_Load(object sender, EventArgs e)
        {
            textBox1.Text = "";//初始状态下输入框为0
            label1.Text = "";//初始状态下标签框置空
        }
      
        //输入框
        private void textBox1_TextChanged(object sender, EventArgs e)
        {


        }
        //小数点按钮设置
        private void dot_Click(object sender, EventArgs e)
        {
            num += this.dot.Text;
            textBox1.Text = num;
        }
        //数字按钮设置0-9
        private void zero_Click(object sender, EventArgs e)
        {
            num += this.zero.Text;
            textBox1.Text = num;
            label1.Text = textBox1.Text;
        }
        private void one_Click(object sender, EventArgs e)
        {
            num += this.one.Text;
            textBox1.Text = num;
            label1.Text = textBox1.Text;
        }


        private void two_Click(object sender, EventArgs e)
        {
            num += this.two.Text;
            textBox1.Text = num;
            label1.Text = textBox1.Text;
        }


        private void three_Click(object sender, EventArgs e)
        {
            num += this.three.Text;
            textBox1.Text = num;
            label1.Text = textBox1.Text;
        }


        private void four_Click(object sender, EventArgs e)
        {
            num += this.four.Text;
            textBox1.Text = num;
            label1.Text = textBox1.Text;
        }


        private void five_Click(object sender, EventArgs e)
        {
            num += this.five.Text;
            textBox1.Text = num;
            label1.Text &
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值