基于Delph的计算器毕业实习报告含源代码-报告.doc_第1页
基于Delph的计算器毕业实习报告含源代码-报告.doc_第2页
基于Delph的计算器毕业实习报告含源代码-报告.doc_第3页
基于Delph的计算器毕业实习报告含源代码-报告.doc_第4页
基于Delph的计算器毕业实习报告含源代码-报告.doc_第5页
已阅读5页,还剩2页未读 继续免费阅读

下载本文档

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

文档简介

基于Delph的计算器毕业实习报告含源代码-报告基于Delph的计算器毕业实习报告含源代码|计算机实习报告|毕业实习报告|暑假实习报告总结终于走进了大学生活的最后阶段,大学生活马上就要结束了,我们要证明一下自己所学的知识能不能在社会上派上用场,毕业实习就是最好证明自己的方法。实习是我们从大学走向社会的第一步,为了是让我们今后走向工作岗位后能很快地适应。实习的方法有很多,可以到各公司去工作实习,也可以在学校里用自己所学的东西做出点实际的东西来。我的实习就是在学校里用Delphi做了一个简单的程序。程序虽然小但很实用,就是做一个简单的计算器。计算器是大家在日常生活中经常用到的,其功能也越来越强大。在我看来Delphi是一种功能很强大的开发工具,不论是从程序语言结构的严谨性,还是从模块功能的完整性来看都不次与C+。Delphi语言的结构很有条理,思路很清晰,让人看了一目了然,而且语法结构也很简单,程序设计相对容易。在日常的数据库管理工作中,Delphi起了很的大的作用,所以对Delphi的学习对我们今后的工作是相当重要的。Delphi是我最近才开始学的,有很多语句我用的不是很熟练,有的跟本就不会用。虽然是做一个小小的计算器,但还是困扰了我很长时间。只能请教懂Delphi的同学和知道老师了。最后做出的计算器外观是不怎么好看,功能也只有四则运算,但我觉得已经很欣慰了。不关怎么说毕竟我付出了劳动。下面是我做的计算器的界面: 其源代码如下:unit Unit1;interfaceuses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs, Buttons, StdCtrls, ExtCtrls;type TForm1 = class(TForm) Panel1: TPanel; Panel2: TPanel; SpeedButton7: TSpeedButton; SpeedButton8: TSpeedButton; SpeedButton9: TSpeedButton; SpeedButton13: TSpeedButton; SpeedButton4: TSpeedButton; SpeedButton5: TSpeedButton; SpeedButton6: TSpeedButton; SpeedButton12: TSpeedButton; SpeedButton1: TSpeedButton; SpeedButton2: TSpeedButton; SpeedButton3: TSpeedButton; SpeedButton11: TSpeedButton; SpeedButton14: TSpeedButton; SpeedButton15: TSpeedButton; SpeedButton10: TSpeedButton; StaticText1: TStaticText; SpeedButton0: TSpeedButton; SpeedButton16: TSpeedButton; SpeedButton17: TSpeedButton; GroupBox1: TGroupBox; procedure SpeedButton1Click(Sender: TObject); procedure FormCreate(Sender: TObject); procedure SpeedButton11Click(Sender: TObject); procedure SpeedButton15Click(Sender: TObject); procedure SpeedButton16Click(Sender: TObject); procedure SpeedButton17Click(Sender: TObject); private Private declarations public Public declarations end;var Form1: TForm1; restart: Boolean; isfirst: Boolean; fir_num,sec_num: String; sign: integer; result: real; save: String;implementation$R *.dfmfunction count(sign: integer):real;begin case sign of 1: result:=strtofloat(fir_num)+strtofloat(sec_num); /为加号时 2: result:=strtofloat(fir_num)-strtofloat(sec_num); /为减号时 3: result:=strtofloat(fir_num)*strtofloat(sec_num); /为乘号时 4: begin try result:=strtofloat(fir_num)/strtofloat(sec_num); /为除号时 except ShowMessage(错误!); form1.close; end; /除数为0时,做出异常处理 end; end;end;procedure TForm1.SpeedButton1Click(Sender: TObject);vari: integer;beginif restart then /如果是重新开始输入,则清除原来的操作数,并设置isfirst为True begin isfirst:=True; fir_num:=; sec_num:=; restart:=False; end;if isfirst then /如果是第一个操作数 begin if (sender as TSpeedButton).Caption=. then /如果输入的是小数点 begin if (strlen(pChar(fir_num)0) and (fir_num1=0) then /如果最高位为0 begin if (sender as TSpeedButton).Caption=.) then fir_num:=0. else begin if strlen(pChar(fir_num)1 then /如果是小数,则继续输入 fir_num:=fir_num+(sender as TSpeedButton).Caption else fir_num:=(sender as TSpeedButton).Caption; /如果不是小数,则去掉最高位的0 end; end else fir_num:=fir_num+(sender as TSpeedButton).Caption; StaticText1.Caption:=fir_num; endelse begin if (sender as TSpeedButton).Caption=. then /如果第二个操作数并未输入 begin if (strlen(pChar(sec_num)0) and (sec_num1=0) then /如果最高位为0 begin if (sender as TSpeedButton).Caption=.) then sec_num:=0. else begin if strlen(pChar(sec_num)1 then /如果是小数,则继续输入 sec_num:=sec_num+(sender as TSpeedButton).Caption else sec_num:=(sender as TSpeedButton).Caption; /如果不是小数,则去掉最高位的0 end; end else sec_num:=sec_num+(sender as TSpeedButton).Caption; StaticText1.Caption:=sec_num; end;end;procedure TForm1.FormCreate(Sender: TObject);beginStaticText1.Caption:=0.; /设置StaticText1初始显示为0.restart:=False;Isfirst:=True;fir_num:=;sec_num:=;end;procedure TForm1.SpeedButton11Click(Sender: TObject);beginif (fir_num) and (sec_num) then/如果两各操作数都不为空 begin result:=count(sign); /调用函数,返回计算结果 fir_num:=floattostr(result); sec_num:=; StaticText1.Caption:=floattostr(result); end;sign:=(sender as TSpeedButton).Tag;isfirst:=False;restart:=False;end;procedure TForm1.SpeedButton15Click(Sender: TObject);beginif (sec_num) then/如果第二个操作数不为空则返回结果 begin result:=count(sign); fir_num:=; fir_num:=fir_num+floattostr(result); StaticText1.Caption:=floattostr(result); sec_num:=; end; restart:=true;end;procedure TForm1.SpeedButton16Click(Sender: TObject);beginrestart:=True;fir_num:=;sec_num:=;self.StaticText1.Caption:=0.;end;procedure TForm1.SpeedButton17Click(Sender: TObject);beginClose;end;end. 根据计算器的

温馨提示

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

评论

0/150

提交评论