實(shí)驗(yàn)一程序流程設(shè)計(jì).ppt_第1頁(yè)
實(shí)驗(yàn)一程序流程設(shè)計(jì).ppt_第2頁(yè)
實(shí)驗(yàn)一程序流程設(shè)計(jì).ppt_第3頁(yè)
實(shí)驗(yàn)一程序流程設(shè)計(jì).ppt_第4頁(yè)
實(shí)驗(yàn)一程序流程設(shè)計(jì).ppt_第5頁(yè)
已閱讀5頁(yè),還剩24頁(yè)未讀, 繼續(xù)免費(fèi)閱讀

下載本文檔

版權(quán)說(shuō)明:本文檔由用戶提供并上傳,收益歸屬內(nèi)容提供方,若內(nèi)容存在侵權(quán),請(qǐng)進(jìn)行舉報(bào)或認(rèn)領(lǐng)

文檔簡(jiǎn)介

實(shí)驗(yàn)一程序流程設(shè)計(jì) 1 理解大小寫轉(zhuǎn)換函數(shù) 在文本框中輸入文本串 按 轉(zhuǎn)大寫 按鈕 文本中的英文字母變?yōu)榇髮?按 轉(zhuǎn)小寫 按鈕 文本中的英文字母變?yōu)樾?如圖所示 設(shè)計(jì)代碼方法一 首先設(shè)計(jì)文本框的InteractiveChange事件代碼 使得輸入的字符存入表單的Tag屬性 用來(lái)存儲(chǔ)程序所需的任何額外數(shù)據(jù) 中 thisform tag this value編寫 大寫 按鈕Command1的Click事件代碼 thisform text1 value upper thisform tag 編寫 小寫 按鈕Command2的Click事件代碼 thisform text1 value lower thisform tag 編寫 復(fù)原 按鈕Command2的Click事件代碼 thisform text1 value thisform tag 方法二 首先在表單的load事件代碼中聲明一個(gè)全局變量a Publica設(shè)計(jì)文本框的InteractiveChange事件代碼 使得輸入的字符存入表單的Tag屬性 用來(lái)存儲(chǔ)程序所需的任何額外數(shù)據(jù) 中 a this value編寫 大寫 按鈕Command1的Click事件代碼 thisform text1 value upper a 編寫 小寫 按鈕Command2的Click事件代碼 thisform text1 value lower a 編寫 復(fù)原 按鈕Command2的Click事件代碼 thisform text1 value a 2 輸入3個(gè)不同的數(shù) 將他們從大到小排序 分析 先將a與b比較 把較大者放入a中 小者放入b中 再將a與c比較 把較大者放入a中 小者放入c中 此時(shí)a為三者中的最大者 最后將b與c比較 把較大者放入b中 小者放入c中 此時(shí)a b c已由大到小順序排列 流程圖如下 編寫Command1的Click事件代碼 a thisform text1 valueb thisform text2 valuec thisform text3 valueIFb ad aa bb dENDIFIFc ad aa cc dENDIF IFc bd bb cc dENDIFthisform label2 caption STR a 4 thisform label3 caption STR b 4 thisform label4 caption STR c 4 3 設(shè)計(jì)個(gè)人納稅計(jì)算程序 稅法 規(guī)定 工資 薪金所得 使用超額累進(jìn)稅率 以每月收入額減去800元后的余額 為應(yīng)納稅所得額 其稅率表見(jiàn)表5 3 Text1的KeyPress事件代碼 LPARAMETERSnKeyCode nShiftAltCtrlIFnKeyCode 13n val this value IFn 800MESSAGEBOX 不超過(guò)800元 不必納稅 ELSES1 500 0 05S2 2000 0 15S3 5000 0 2S4 20000 0 25S5 40000 0 3S6 60000 0 35S7 80000 0 4S8 100000 0 45n n 800 DOCASECASEn 500s n 0 05CASEn 2000s n 500 0 1 s1CASEn 5000s n 2000 0 15 s2CASEn 20000s n 5000 0 2 s3CASEn 40000s n 20000 0 25 s4CASEn 60000s n 40000 0 3 s5CASEn 80000s n 60000 0 35 s6 CASEn 100000s n 80000 0 4 s7OTHERWISEs n 100000 0 45 s8ENDCASEthisform label2 caption 共計(jì)納稅 STR round s 2 8 2 元 this SelStart 0this SelLength LEN this value ENDIFENDIF 4 完備數(shù) 是指一個(gè)數(shù)恰好等于它的因子之和 如6的因子為1 2 3 而6 1 2 3 因而6就是完備數(shù) 編制程序 找出1 1000之間的全部 完備數(shù) 分析 依題意可知 要想知道一個(gè)自然數(shù)是否為完備數(shù) 首先必須找除其所有因數(shù) 從2開(kāi)始到這個(gè)數(shù)的最打因數(shù)為止 偶數(shù)不大于其值的二分之一 奇數(shù)不大于其值的三分之一 進(jìn)行整除判斷 凡是可以被整除的數(shù)均為這個(gè)數(shù)的因數(shù) 由此 可畫出其流程圖 編寫Command1的Click事件代碼 thisform container1 list1 clearforn 1to1000t iif n 2 0 n 2 n 3 a 2s 1dowhilea tifn a 0s s aendifa a 1enddoifs nthisform container1 list1 additem str n 6 endifendfor 編寫Command2的Click事件代碼 releasethisform 5 輸出99乘法表 格式如下圖 1 利用雙重循環(huán)分別處理行 列的輸出 編寫Command1的Click事件代碼 Thisform list1 clearThisform list1 addlistitem 1 1 fork 1to9Thisform list1 addlistitem str k 3 1 k 1 endforforn 1to9Thisform list1 addlistitem str n 3 n 1 1 fork 1tonThisform list1 addlistitem str k n 3 n 1 k 1 endforEndfor編寫Command2的Click事件代碼 releasethisform 6 小學(xué)生做加減法的算術(shù)練習(xí)程序 計(jì)算機(jī)連續(xù)地隨機(jī)給出兩位數(shù)的加減法算術(shù)題 要求學(xué)生回答 答對(duì)的打 答錯(cuò)的打 將做過(guò)的題目存放在列表框中備查 并隨時(shí)給出答題的正確率 分析 隨機(jī)函數(shù)RAND 返回一個(gè) 0 1 之間的隨機(jī)小數(shù) 為了生成某個(gè)范圍內(nèi)的隨機(jī)整數(shù) 可以使用以下公式 Int 最大值 最小值 1 RAND 最小值 其中最大值和最小值為指定范圍中的最大 最小數(shù) 給出部分由窗體的激活 activate 事件代碼完成 a int 10 90 rand b int 10 90 rand p int 2 rand docasecasep 0this text1 value str a 3 str b 3 this text1 tag str a b 將本題答案放入text1 tag中casep 1ifa bt aa bb tendif this text1 value str a 3 str b 3 this text1 tag str a b 將本題答案放入text1 tag中endcasen val this tag this tag str n 1 this text2 setfocusthis text2 value 編寫Command1的Click事件代碼 ifval thisform text2 value val thisform text1 tag item allt thisform text1 text thisform text2 text k val thisform list1 tag thisform list1 tag str k 1 elseitem allt thisform text1 text thisform text2 text endifthisform list1 additem item 1 將題目和答案放入列表框中的第一項(xiàng)x vAL thisform list1 tag val thisform tag p 正確率為 chr 13 str x 100 5 2 thisform label1 caption 共 allt thisform tag 題 pthisform activate 調(diào)用出題代碼 7 使用命令按鈕組設(shè)計(jì)簡(jiǎn)易計(jì)算器程序 如圖所示 編寫commandgroup1的click事件代碼 ifthisform tag T thisform text1 value allt right str this value 1 thisform tag elsea thisform text1 valuethisform text1 value a allt right str this value 1 endif編寫 按鈕command11的click事件代碼 a thisform text1 valuethisform text1 value a 編寫 按鈕command12的click事件代碼 a thisform text1 valuethisform text1 value allt str a thisform tag T 編寫 按鈕command12的click事件代碼 a thisform text1 valuethisform text1 value a thisform tag 編寫 按鈕command12的click事件代碼 a thisform text1 v

溫馨提示

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

評(píng)論

0/150

提交評(píng)論