1、浙江大学远程教育数据库应用程序设计离线作业浙江大学远程教育学院数据库应用程序设计课程作业姓名:学号:年级:学习中心:作业第一章1.5 如何保存Delphi的项目?尝试自己动手创建一个项目,并保存。答:执行 File|Save All 菜单命令或单击工具栏中的 Save All 按钮便可保存,在保存时可以对工程文件和单元文件进行改名,但后缀名不能改。保存文件之后,单击工具中的 Run 按钮或按 F9 键,系统将开始编译、连接、运行该工程。1.7 尝试设计如图110所示的窗体。(图见教材P15页图110)图110第二章2.8设计如图25所示的界面。单击“按钮1”或“按钮2”时在标签上显示用户所执行
2、的操作。单击“开启/停用按钮”可控制“按钮1”和“按钮2”是否可用,单击“退出系统”按钮时,结束程序的运行。2.9 设计如图26所示的界面。当单击按钮时,可控制文本框中字体的颜色。图25 图26 unittest;interface uses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,StdCtrls;type TForm1=class(TForm) showLabel:TLabel; btn1:TButton; /按钮 1 btn2:TButton; /按钮 2 ctlBtn:TBu
3、tton; /开启停用按钮exitBtn:TButton; /退出按钮 procedurebtn1Click(Sender:TObject); procedurebtn2Click(Sender:TObject); procedureexitBtnClick(Sender:TObject); procedurectlBtnClick(Sender:TObject); private Privatedeclarations public Publicdeclarations end;var Form1:TForm1; ctlStatus:integer=0; /控制按钮 1 和 2 的开启和关闭
4、,0 表示当前为开启,1 表示关闭implementation$R*.dfmprocedureTForm1.btn1Click(Sender:TObject);begin form1.showLabel.Caption:=您点击了按钮 1;end;procedureTForm1.btn2Click(Sender:TObject);begin form1.showLabel.Caption:=您点击了按钮 2;end;procedureTForm1.exitBtnClick(Sender:TObject);begin form1.Close;end; procedureTForm1.ctlBtn
5、Click(Sender:TObject);begin ifctlStatus=0then begin form1.btn1.Enabled:=false; form1.btn2.Enabled:=false; ctlStatus:=1; end else begin form1.btn1.Enabled:=true; form1.btn2.Enabled:=true; ctlStatus:=0; end;end;end.2.9:unittest;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls
6、,Forms, Dialogs,StdCtrls;type TForm1=class(TForm) Label1:TLabel; Edit1:TEdit; btnRed:TButton; btnGreen:TButton; btnBlue:TButton; procedurebtnRedClick(Sender:TObject); procedurebtnGreenClick(Sender:TObject); procedurebtnBlueClick(Sender:TObject); private Privatedeclarations public Publicdeclarations
7、end;var Form1:TForm1;implementation$R*.dfmprocedureTForm1.btnRedClick(Sender:TObject);begin form1.Edit1.Font.Color:=clred;end;procedureTForm1.btnGreenClick(Sender:TObject);begin form1.Edit1.Font.Color:=clgreen;end; procedureTForm1.btnBlueClick(Sender:TObject);begin form1.Edit1.Font.Color:=clblue;end
8、;end.第三章3.8 下列实数中哪些是合法的,哪些是不合法的?不合法的请说明理由。(A)0.25E+02 (B).25+2 (C)25E+2(D)34.5 (E).123 (F)-3E-4(A)合法,即为 25(B)不合法,小数点前必须有数字,如表示为 0.25+2(C)合法,即为 2500(D)合法,即为 34.5(E)不合法,同(2)(F)合法,即为0.00033.12 数学式子sin30。写成Delphi表达式是下列哪个?(A)Sin30 (B)Sin(30) (C)SIN(30。) (D)Sin(30*Pi/180)D,需要把角度转化为弧度第四章4.7 利用3个数字编辑框分别输入小时
9、、分、秒,换算共有多少秒,然后使用标签输出。 unittest;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,StdCtrls,Spin;type TForm1=class(TForm) SpinEdit1:TSpinEdit; Label1:TLabel; Label2:TLabel; SpinEdit2:TSpinEdit; Label3:TLabel; SpinEdit3:TSpinEdit; Label4:TLabel; procedureSpinEdi
10、t1Change(Sender:TObject); procedureSpinEdit2Change(Sender:TObject); procedureSpinEdit3Change(Sender:TObject); private Privatedeclarations procedureCalculateTimeToSencond(timeKind:String;time:integer); public Publicdeclarations end;var Form1:TForm1; hour:integer=0; minute:integer=0; second:integer=0;
11、 tot:integer=0;implementation$R*.dfmprocedureTForm1.CalculateTimeToSencond(timeKind:String;time:integer);begin iftimeKind=hhthen hour:=time elseiftimeKind=mithen minute:=time elseiftimeKind=ssthen second:=time; tot:=hour*60*60+minute*60+second; form1.Label4.Caption:=总共为+IntToStr(tot)+秒;end;procedure
12、TForm1.SpinEdit1Change(Sender:TObject);begin Form1.CalculateTimeToSencond(hh,StrToInt(Form1.SpinEdit1.Text);end;procedureTForm1.SpinEdit2Change(Sender:TObject);begin Form1.CalculateTimeToSencond(mi,StrToInt(Form1.SpinEdit2.Text);end; procedureTForm1.SpinEdit3Change(Sender:TObject);begin Form1.Calcul
13、ateTimeToSencond(ss,StrToInt(Form1.SpinEdit3.Text);end;end.4.8 在编辑框中输入一个实数,利用备注框输出该实数及其平方和平方根。unitUnit1;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,StdCtrls;type TForm1=class(TForm) Edit1:TEdit; Label1:TLabel; Memo1:TMemo; Label2:TLabel; procedureEdit1Ch
14、ange(Sender:TObject); private Privatedeclarations public Publicdeclarations end;var Form1:TForm1; num1:Real; /原实数 num2:Real; /实数平方 num3:Real; /实数平方根implementation$R*.dfmprocedureTForm1.Edit1Change(Sender:TObject);begin ifform1.Edit1.Textthen begin num1:=StrToFloat(form1.Edit1.Text); num2:=Sqr(num1);
15、 num3:=Sqrt(num1); form1.Memo1.Lines.Clear; form1.Memo1.Lines.Add(实数为 :+FloatToStr(num1); form1.Memo1.Lines.Add(平方为 :+FloatToStr(num2); form1.Memo1.Lines.Add(平方根为 :+FloatToStr(num3); end;end;end.第五章5.11 任意给定3个实数,按照从大到小的顺序依次输出这3个数。unitUnit1;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Gra
16、phics,Controls,Forms, Dialogs,StdCtrls;type TForm1=class(TForm) num1Edit:TEdit; Label1:TLabel; Label2:TLabel; resultLabel:TLabel; num2Edit:TEdit; num3Edit:TEdit; procedurenum1EditChange(Sender:TObject); procedurenum2EditChange(Sender:TObject); procedurenum3EditChange(Sender:TObject); private Private
17、declarations procedureCompareNumber(); public Publicdeclarations end;var Form1:TForm1; num1:Real; /数字 1 num2:Real; /数字 2 num3:Real; /数字 3 compnum:Real;/比较时转换 2 数 outStr:String;/输出结果;implementation$R*.dfmprocedureTForm1.CompareNumber();begin if (trim(form1.num1Edit.Text) ) And (trim(form1.num2Edit.Te
18、xt) ) And(trim(form1.num3Edit.Text)then begin num1:=StrToFloat(form1.num1Edit.Text); num2:=StrToFloat(form1.num2Edit.Text); num3:=StrToFloat(form1.num3Edit.Text); ifnum2num1then begin compnum:=num1; num1:=num2; num2:=compnum; end; ifnum3num1then begin compnum:=num1; num1:=num3; num3:=compnum; end; i
19、fnum3num2then begin compnum:=num2; num2:=num3; num3:=compnum; end; outStr:=FloatToStr(num1)+,+FloatToStr(num2)+,+FloatToStr(num3); form1.resultLabel.Caption:=outStr; end;end;procedureTForm1.num1EditChange(Sender:TObject);begin form1.CompareNumber;end;procedureTForm1.num2EditChange(Sender:TObject);be
20、gin form1.CompareNumber;end;procedureTForm1.num3EditChange(Sender:TObject);begin form1.CompareNumber;end;end.5.13 假设工资的增幅标准为:若基本工资大于等于1000元,增加工资20%;若小于1000元大于等于800元,则增加工资15%;若小于800元,则增加工资10%。请根据用户在文本框中输入的基本工资,计算出增加后的工资。 unitUnit1;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Cont
21、rols,Forms, Dialogs,StdCtrls;type TForm1=class(TForm) Label1:TLabel; Edit1:TEdit; Label2:TLabel; resultLabel:TLabel; procedureEdit1Change(Sender:TObject); private Privatedeclarations public Publicdeclarations end;var Form1:TForm1; salary:Real; outSalary:Real;implementation$R*.dfmprocedureTForm1.Edit
22、1Change(Sender:TObject);begin salary:=StrToFloat(form1.Edit1.Text); if(salary=1000)then outSalary:=salary*(1+0.2) elseif(salary=800)then outSalary:=salary*(1+0.15) elseif(salary800)then outSalary:=salary*(1+0.1); form1.resultLabel.Caption:=FloatToStr(outSalary);end;end.第六章6.5 设s=1X2X3XXn,求s不大于20000时最大的n。unitUnit1;interfaceuses Windows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms, Dialogs,StdCtrls;type TForm1=class(TForm) Label1:TLabel; Edit1:TEdit; Label2:TLabel; resultLabel:TLabel; procedureFormCreate(Sender:TObject); private Privatedeclarations public Publi
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1