C编的计算器Word版_第1页
C编的计算器Word版_第2页
C编的计算器Word版_第3页
C编的计算器Word版_第4页
C编的计算器Word版_第5页
已阅读5页,还剩6页未读 继续免费阅读

下载本文档

版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领

文档简介

1、网络程序设计作业(三)学院:教育科学与技术学院班级:10级教计三班姓名:张敏学号:100401041334日期:2011年11月7日1 / 11在线计算器的设计与实现一、界面设计1.界面截图如下:2设计步骤:(1)打开Visual Web Developer 2008软件,把“default.aspx”重命名为“zaixianjisuanji.aspx”。(2)打开该项的设计界面,在div块标签中输入“在线计算器”。(3)在工具箱拖入一个文本框TextBox,在属性栏中设置其属性值。(4)拖入一个Table控件,设置其行列分别为5,4。并设置其大小边框值等。(5)在每个格子里拖入一个butto

2、n按钮控件,在第五行合并前两个单元格。并如上图设置其Text的值。二、程序设计using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;public partial class _Default : System.Web.UI.Pageprivate Calulate obj1; public void Page_Load(object sender, EventArgs e) if (!

3、IsPostBack) Calulate obj1 = new Calulate(); ViewState"result" = obj1; else obj1 = ViewState"result" as Calulate; public void sum(float a) if (obj1.s != "-") if (obj1.b = 1) obj1.d = a; else obj1.d = obj1.d * 10 + a; ViewState"result" = obj1; else if (obj1.b =

4、1) obj1.d = -a; else obj1.d = obj1.d * 10 - a; ViewState"result" = obj1; /四则运算 public void sum1(float a) if (obj1.c = true && obj1.a = false) obj1.result = a; ViewState"result" = obj1; if (obj1.sign = "+" && obj1.c = false && obj1.a = true) obj1.

5、result = obj1.result + a; ViewState"result" = obj1; if (obj1.sign = "-" && obj1.c = false && obj1.a = true) obj1.result = obj1.result - a; ViewState"result" = obj1; if (obj1.sign = "*" && obj1.c = false && obj1.a = true) obj1.re

6、sult = obj1.result * a; ViewState"result" = obj1; if (obj1.sign = "/" && obj1.c = false && obj1.a = true) obj1.result = obj1.result / a; ViewState"result" = obj1; /数字键 protected void Button18_Click(object sender, EventArgs e) if (obj1.e = false) dele();

7、obj1.e = true; obj1.b+; float d = 1; sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button9_Click(object sender, EventArgs e) sum1(obj1.d); obj1.c = false; obj1.a = true; obj1.e = true; obj1.b = 0; obj1.s = "" obj1.sign = Button9.Text; TextBox

8、1.Text = obj1.sign; ViewState"result" = obj1; protected void Button12_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 2; sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button2_Click(object sen

9、der, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 3; sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button13_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 4; sum(d); V

10、iewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button7_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 5; sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button4_Cli

11、ck(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 6; sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button1_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d =

12、7; sum(d); ViewState"result = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button5_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 8;sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString(); protected void Button

13、6_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 9; sum(d);ViewState"result" = obj1;TextBox1.Text = obj1.d.ToString(); protected void Button10_Click(object sender, EventArgs e) sum1(obj1.d); obj1.c = false; obj1.a = true; obj1.e = true; o

14、bj1.b = 0; obj1.s = "" obj1.sign = Button10.Text; TextBox1.Text = obj1.sign; ViewState"result" = obj1; protected void Button11_Click(object sender, EventArgs e) sum1(obj1.d); obj1.c = false; obj1.a = true; obj1.e = true; obj1.b = 0; obj1.s = "" obj1.sign = Button11.Text

15、; TextBox1.Text = obj1.sign; ViewState"result" = obj1; protected void Button118_Click(object sender, EventArgs e) sum1(obj1.d); obj1.c = false; obj1.a = true; obj1.e = true; obj1.b = 0; obj1.s = "" obj1.sign = Button118.Text; TextBox1.Text = obj1.sign; ViewState"result"

16、 = obj1; protected void Button16_Click(object sender, EventArgs e) if (obj1.e = false) dele(); obj1.e = true; obj1.b+; float d; d = 0;sum(d); ViewState"result" = obj1; TextBox1.Text = obj1.d.ToString();/清空 protected void Button19_Click(object sender, EventArgs e) obj1.b = 0; obj1.result =

17、0; obj1.sign = "" obj1.a = false; obj1.c = true; obj1.s = "" obj1.d = 0; TextBox1.Text = obj1.result.ToString(); protected void dele() obj1.b = 0; obj1.result = 0; obj1.sign = "" obj1.a = false; obj1.c = true; obj1.d = 0; /等号 protected void Button17_Click(object sender,

18、 EventArgs e) obj1.b = 0; sum1(obj1.d); obj1.a = false; obj1.e = false; obj1.s = "" ViewState"result" = obj1; TextBox1.Text = obj1.result.ToString(); protected void TextBox1_TextChanged(object sender, EventArgs e) /正负 protected void Button120_Click(object sender, EventArgs e) obj1.s = "-" ViewState"result" = obj1; TextBox1.Text = "-"/时间 protected void Button122_Click(object sender, EventArgs e) DateTime currentTime = System.DateTime.Now; TextBox1.Text = System.D

温馨提示

  • 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
  • 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
  • 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
  • 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
  • 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
  • 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
  • 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。

评论

0/150

提交评论