2017浙大遠程數據庫應用程序設計離線作業_第1頁
2017浙大遠程數據庫應用程序設計離線作業_第2頁
2017浙大遠程數據庫應用程序設計離線作業_第3頁
2017浙大遠程數據庫應用程序設計離線作業_第4頁
2017浙大遠程數據庫應用程序設計離線作業_第5頁
已閱讀5頁,還剩16頁未讀 繼續免費閱讀

下載本文檔

版權說明:本文檔由用戶提供并上傳,收益歸屬內容提供方,若內容存在侵權,請進行舉報或認領

文檔簡介

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 unit test;  interface   uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialo

3、gs, StdCtrls;  type     TForm1 = class(TForm)         showLabel: TLabel;         btn1: TButton;    /按鈕 1         btn2: TButton;    /按鈕 2   &

4、#160;     ctlBtn: TButton;    /開啟停用按鈕exitBtn: TButton;    /退出按鈕         procedure btn1Click(Sender: TObject);         procedure btn2Click(Sender: TObject);         p

5、rocedure exitBtnClick(Sender: TObject);         procedure ctlBtnClick(Sender: TObject);     private          Private declarations      public          Publ

6、ic declarations       end;  var     Form1: TForm1;     ctlStatus:integer = 0;        /控制按鈕 1 和 2 的開啟和關閉,0 表示當前為開啟,1 表示關閉 implementation  $R *.dfm  procedure TFo

7、rm1.btn1Click(Sender: TObject);begin      form1.showLabel.Caption := '您點擊了按鈕 1' end;  procedure TForm1.btn2Click(Sender: TObject); begin       form1.showLabel.Caption := '您點擊了按鈕 2' end

8、;  procedure TForm1.exitBtnClick(Sender: TObject); begin     form1.Close; end;   procedure TForm1.ctlBtnClick(Sender: TObject); begin     if ctlStatus = 0 then         be

9、gin           form1.btn1.Enabled := false;           form1.btn2.Enabled := false;           ctlStatus := 1;         end     else  

10、       begin           form1.btn1.Enabled := true;           form1.btn2.Enabled := true;           ctlStatus := 0;         end; end;

11、60; end.  2.9: unit test;  interface  uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm

12、1 = class(TForm)         Label1: TLabel;         Edit1: TEdit;         btnRed: TButton;         btnGreen: TButton;         btnBlue: TButton;

13、         procedure btnRedClick(Sender: TObject);        procedure btnGreenClick(Sender: TObject);         procedure btnBlueClick(Sender: TObject);      private   

14、60;      Private declarations      public          Public declarations       end;  var     Form1: TForm1;  implementation  $R *.dfm  &#

15、160;procedure TForm1.btnRedClick(Sender: TObject); begin      form1.Edit1.Font.Color := clred;end;  procedure TForm1.btnGreenClick(Sender: TObject); begin       form1.Edit1.Font.Color := clgreen; 

16、;end;   procedure TForm1.btnBlueClick(Sender: TObject); begin         form1.Edit1.Font.Color := clblue; end;  end.第三章3.8 下列實數中哪些是合法的,哪些是不合法的?不合法的請說明理由。(A)0.25E+02(B).25+2(C)25E+2(D)34.5(E).123(F)-3E-4(A)合法,即為 25 (B)不合法,小

17、數點前必須有數字,如表示為 0.25+2 (C)合法,即為 2500 (D)合法,即為 34.5 (E)不合法,同(2) (F)合法,即為0.0003  3.12 數學式子sin30。寫成Delphi表達式是下列哪個?(A)Sin30(B)Sin(30)(C)SIN(30。)(D)Sin(30*Pi/180)D,需要把角度轉化為弧度  第四章4.7 利用3個數字編輯框分別輸入小時、分、秒,換算共有多少秒,然后使用標簽輸出。 unit test;  interface 

18、0;uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls, Spin;  type     TForm1 = class(TForm)         SpinEdit1:

19、 TSpinEdit;         Label1: TLabel;         Label2: TLabel;         SpinEdit2: TSpinEdit;         Label3: TLabel;         SpinEdit3: TSpinEdit;&#

20、160;        Label4: TLabel;         procedure SpinEdit1Change(Sender: TObject);         procedure SpinEdit2Change(Sender: TObject);         procedure SpinEdit3Change(Sender:&#

21、160;TObject);        private          Private declarations          procedure CalculateTimeToSencond(timeKind:String; time:integer);     public          Pu

22、blic declarations        end;  var     Form1: TForm1;     hour: integer = 0;     minute: integer = 0;     second: integer = 0;    

23、 tot:integer = 0;  implementation  $R *.dfm  procedure TForm1.CalculateTimeToSencond(timeKind:String; time:integer); begin     if timeKind = 'hh' then         hour :=&

24、#160;time     else if timeKind = 'mi' then         minute := time     else if timeKind = 'ss' then         second := time;  

25、    tot := hour * 60 * 60 + minute * 60 + second;      form1.Label4.Caption := '總共為' + IntToStr(tot) + '秒' end;  procedure TForm1.SpinEdit1Chang

26、e(Sender: TObject); begin       Form1.CalculateTimeToSencond('hh', StrToInt(Form1.SpinEdit1.Text); end;  procedure TForm1.SpinEdit2Change(Sender: TObject); begin       Form1.CalculateTimeToSencond('mi

27、9;, StrToInt(Form1.SpinEdit2.Text); end;   procedure TForm1.SpinEdit3Change(Sender: TObject); begin       Form1.CalculateTimeToSencond('ss', StrToInt(Form1.SpinEdit3.Text); end;  end.  4.8 在編輯框中輸入一個實數,利用備注框輸

28、出該實數及其平方和平方根。unit Unit1; interface uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm1 = class(TForm) &

29、#160;       Edit1: TEdit;         Label1: TLabel;         Memo1: TMemo;         Label2: TLabel;         procedure Edit1Change(Sender: TObject);  

30、   private          Private declarations      public          Public declarations      end;  var     Form1: TForm1;     num1 : Rea

31、l;    /原實數     num2 : Real;    /實數平方     num3 : Real;    /實數平方根 implementation  $R *.dfm  procedure TForm1.Edit1Change(Sender: TObject); begin        

32、 if form1.Edit1.Text <> '' then               begin                     num1 := StrToFloat(form1.Edit1.Text);             

33、0;       num2 := Sqr(num1);                     num3 := Sqrt(num1);                      form1.Memo1.Lines.Clear;         

34、60;           form1.Memo1.Lines.Add('實數為  : ' + FloatToStr(num1);                     form1.Memo1.Lines.Add('平方為  : ' + FloatToStr(num2);      

35、              form1.Memo1.Lines.Add('平方根為  : ' + FloatToStr(num3);               end; end; end. 第五章5.11 任意給定3個實數,按照從大到小的順序依次輸出這3個數。 unit Unit1;  interface &#

36、160;uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm1 = class(TForm)         num1Edit: TEdi

37、t;         Label1: TLabel;         Label2: TLabel;         resultLabel: TLabel;         num2Edit: TEdit;         num3Edit: TEdit;     &

38、#160;   procedure num1EditChange(Sender: TObject);          procedure num2EditChange(Sender: TObject);         procedure num3EditChange(Sender: TObject);     private         &

39、#160;Private declarations          procedure CompareNumber();     public          Public declarations      end;  var     Form1: TForm1;     num1&

40、#160;: Real;    /數字 1     num2 : Real;    /數字 2     num3 : Real;    /數字 3     compnum : Real; /比較時轉換 2 數     outStr : String; /輸出結果; implementation

41、60; $R *.dfm  procedure TForm1.CompareNumber(); begin       if  (trim(form1.num1Edit.Text)  <>  '')  And  (trim(form1.num2Edit.Text)  <>  '')  And (trim(form1.num3Edit.Text)

42、0;<> '') then       begin       num1 := StrToFloat(form1.num1Edit.Text);       num2 := StrToFloat(form1.num2Edit.Text);       num3 := StrToFloat(form1.num3Edit.Text);

43、        if num2 > num1 then           begin                 compnum := num1;                 num1 := num2; 

44、                num2 := compnum;           end;        if num3 > num1 then           begin             

45、0;   compnum := num1;                 num1 := num3;                 num3 := compnum;           end;        if num3&

46、#160;> num2 then            begin                 compnum := num2;                 num2 := num3;             

47、60;   num3 := compnum;           end;          outStr := FloatToStr(num1) + ',' + FloatToStr(num2) + ',' + FloatToStr(num3);        &#

48、160;   form1.resultLabel.Caption := outStr;       end; end;  procedure TForm1.num1EditChange(Sender: TObject); begin       form1.CompareNumber; end;  procedure TForm1.num2EditChange(Sender: 

49、TObject); begin       form1.CompareNumber; end;  procedure TForm1.num3EditChange(Sender: TObject); begin       form1.CompareNumber; end;  end. 5.13 假設工資的增幅標準為:若基本工資大于等于1000元,增加工資20%;若小于1000元大于等于800元,則增加工資1

50、5%;若小于800元,則增加工資10%。請根據用戶在文本框中輸入的基本工資,計算出增加后的工資。 unit Unit1;  interface  uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type 

51、0;   TForm1 = class(TForm)         Label1: TLabel;         Edit1: TEdit;          Label2: TLabel;         resultLabel: TLabel;         proce

52、dure Edit1Change(Sender: TObject);     private          Private declarations      public          Public declarations      end;  var     For

53、m1: TForm1;     salary: Real;     outSalary: Real; implementation  $R *.dfm  procedure TForm1.Edit1Change(Sender: TObject); begin       salary := StrToFloat(form1.Edit1.Text); 

54、;       if (salary >= 1000) then             outSalary := salary * (1 + 0.2)       else if (salary < 1000) And (salary >= 800)

55、 then             outSalary := salary * (1 + 0.15)       else if (salary < 800) then             outSalary := salary * (1 

56、+ 0.1);        form1.resultLabel.Caption := FloatToStr(outSalary);  end;  end. 第六章6.5 設s=1X2X3XXn,求s不大于20000時最大的n。unit Unit1;  interface  uses     Windows, Messages, SysUtils, Vari

57、ants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm1 = class(TForm)         Label1: TLabel;         Edit1: TEdit;     

58、60;   Label2: TLabel;         resultLabel: TLabel;         procedure FormCreate(Sender: TObject);     private          Private declarations      public

59、0;         Public declarations      end;  var      Form1: TForm1;     number, n, tot: Integer;  implementation  $R *.dfm  procedure TForm1.FormCreate(

60、Sender: TObject); begin         tot := 1; n := 0;       number := StrToInt(form1.Edit1.Text);       While tot <= number do       begin  

61、        n := n + 1;           tot := tot * n;       end;        form1.resultLabel.Caption := IntToStr(n1); end;  end. 6.10 在標簽上輸出100200

62、之間的所有的奇數,其中3的倍數除外。unit Unit1;  interface  uses     Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm1 = cl

63、ass(TForm)          resultLabel: TLabel;        procedure FormCreate(Sender: TObject);     private          Private declarations      public      

64、;    Public declarations      end;  var     Form1: TForm1;     number, i: Integer;     outStr: String;  implementation  $R *.dfm  procedure TForm1.For

65、mCreate(Sender: TObject); begin         for i:= 100 to 200 do         begin               if i mod 2 <> 0 then       &#

66、160;           if i mod 3 <> 0 then                         outStr := outStr + ' ' + IntToStr(i);        &

67、#160;       form1.resultLabel.Caption := outStr;         end; end;  end.第七章7.4 求1200這200個數的和,當和大于10000時結束計算。(要求使用轉向語句)unit Unit1;  interface  uses     Windows, Messages, SysUtils, 

68、Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm1 = class(TForm)         Label1: TLabel;         procedure FormCreate(Sender:

69、0;TObject);     private          Private declarations      public          Public declarations      end;  var     Form1: TForm1;   

70、0; sum, n : integer;  implementation  $R *.dfm  procedure TForm1.FormCreate(Sender: TObject); begin       sum := 0;       n := 0;        repeat &

71、#160;           n := n + 1;             sum := sum + n;             if (sum > 10000) then break;       until n&#

72、160;>= 200;         form1.Label1.Caption := '總和為' + IntToStr(sum);end;  end. 第八章8.8 編寫函數,輸出100500之間所有能同時被3和13整除的數。unit Unit1;  interface  uses     Windows, Messages, SysUtils

73、, Variants, Classes, Graphics, Controls, Forms,     Dialogs, StdCtrls;  type     TForm1 = class(TForm)         Label1: TLabel;         procedure FormCreate(Send

74、er: TObject);     private          Private declarations          Function checkNum(num:integer):boolean;     public          Public declarations  

75、0;   end;  var      Form1: TForm1;  implementation  $R *.dfm Function TForm1.checkNum(num:integer):boolean;       var n :boolean; begin       if (num mod 3 

76、;= 0) And (num mod 13 = 0) then             n := true       else             n := false;        result := n; end;  procedure TForm1.

溫馨提示

  • 1. 本站所有資源如無特殊說明,都需要本地電腦安裝OFFICE2007和PDF閱讀器。圖紙軟件為CAD,CAXA,PROE,UG,SolidWorks等.壓縮文件請下載最新的WinRAR軟件解壓。
  • 2. 本站的文檔不包含任何第三方提供的附件圖紙等,如果需要附件,請聯系上傳者。文件的所有權益歸上傳用戶所有。
  • 3. 本站RAR壓縮包中若帶圖紙,網頁內容里面會有圖紙預覽,若沒有圖紙預覽就沒有圖紙。
  • 4. 未經權益所有人同意不得將文件中的內容挪作商業或盈利用途。
  • 5. 人人文庫網僅提供信息存儲空間,僅對用戶上傳內容的表現方式做保護處理,對用戶上傳分享的文檔內容本身不做任何修改或編輯,并不能對任何下載內容負責。
  • 6. 下載文件中如有侵權或不適當內容,請與我們聯系,我們立即糾正。
  • 7. 本站不保證下載資源的準確性、安全性和完整性, 同時也不承擔用戶因使用這些下載資源對自己和他人造成任何形式的傷害或損失。

評論

0/150

提交評論