第6章-四则运算计算器-吴勇.docVIP

  • 4
  • 0
  • 约1.35万字
  • 约 20页
  • 2020-09-11 发布于浙江
  • 举报
PAGE PAGE 20 1 一 月 二 月 三 月 产品名称 数量 金额 利润 产品名称 数量 金额 利润 产品名称 数量 金额 利润 合 计 合 计 合 计 四 月 五 月 六 月 产品名称 数量 金额 利润 产品名称 数量 金额 利润 产品名称 数量 金额 利润 合 计 合 计 合 计 第6章 四则运算计算器 6.1 项目一:整数四则运算计算器设计 6.1.1 实验目的:完成一个整数四则运算的计算器,界面如图6.1所示: 图6.1 整数四则运算计算器 6.1.2工作任务三:设计界面完成窗体及控件的属性设置 首先创建一个Windows应用程序,命名为Cacle1,在窗体上添加一个文本框控件和15个按钮控件,设计程序界面如图6.10所示, 图6.10 程序界面设计 窗体、控件及相关属性如表6.1所示。 表6.1 控件属性表 对象 属性 属性值 说明 Form Name Form1 Text 整数四则运算计算器 FormBorderStyle FixedSingle 边框大小设置为固定 MaximizeBox false 不可以最大化 Button Name button1 Text 1 Button Name button2 Text 2 Button Name button3 Text 3 Button Name Button4 Text 4 Button Name button5 Text 5 Button Name button6 Text 6 Button Name button7 Text 7 Button Name button8 Text 8 Button Name button9 Text 9 Button Name button0 Text 0 Button Name btnAdd Text + Button Name btnSubstract Text - Button Name btnMultiply Text × Button Name btnDivide Text / Button Name btnEquals Text = TextBox Name txtOutput ReadOnly true TextAlign Right ReadToLeft No 2.编写程序代码 对照以上流程分析,编写程序代码如下: // 一个整数四则运算的计算器 using System; using System.Drawing; using System.Collections; using System.ComponentModel; using System.Windows.Forms; using System.Data; namespace Calce1 { public class Form1 : System.Windows.Forms.Form { // 存储前一个操作数 protected long iNum1; // 存储运算符 protected char cOperator; // 是否开始输入一个新的数字 protected bool bNumBegins; private System.Windows.Forms.Button button1; private System.Windows.Forms.Button button2; private System.Windows.Forms.Button button3; private System.Windows.Forms.Button button4; private System.Windows.Forms.Button button5; private System.Windows.Forms.Button button6; private System.Windows.Forms.Button button7; private System.Windows.Forms.Button button8; private System.Windows.Forms.Button button9; private System.Windows.Forms.Button btnAdd; private System.Windows.Forms.Button btnSubstract; private System.Windows.Forms.Button btnMultiply; private System.Windows.Forms.Button btnDivide; private Syste

文档评论(0)

1亿VIP精品文档

相关文档