JAVA實驗指導書實驗一_第1頁
JAVA實驗指導書實驗一_第2頁
JAVA實驗指導書實驗一_第3頁
JAVA實驗指導書實驗一_第4頁
JAVA實驗指導書實驗一_第5頁
已閱讀5頁,還剩5頁未讀, 繼續(xù)免費閱讀

下載本文檔

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

文檔簡介

1、Java SE程序設(shè)計實 驗 指 導 手 冊授課教師: 崔毅東實驗指導教師: 崔毅東教學對象: 二年級本科生開課時間: 秋季學期北京郵電大學軟件學院Java語言與編程實驗指導書程保中 孫藝一、實驗一:Java程序編制(基礎(chǔ)練習)1、 實驗目的學生通過使用Java語言進行基本程序的開發(fā),掌握Java通用IDE,練習類的封裝使用、Java基本類庫的使用、利用UML進行簡單建模。2、 實驗內(nèi)容(詳細內(nèi)容見附件一)3、 實驗環(huán)境a) Windowsb) Eclipse 或者 NetBean4、 實驗要求1) 獨立完成實驗內(nèi)容要求2) 熟練使用Java常用 IDE 進行編程3) 需要上交源程序文件4)

2、需要打印實驗報告上交(標準格式見附件二)5、 實驗步驟1) 啟動Java常用 IDE。2)建立project。3)編輯源程序。4)編譯、鏈接并執(zhí)行源程序,看結(jié)果是否正確。5)如果報錯或告警,做必要修改,重復3)5)步驟直到?jīng)]有錯誤和告警。附件一:Project #1 A Math Learning Tool (covers Chapter 2)CSCI 1301 Introduction to ProgrammingArmstrong Atlantic State UniversityDevelop a program that lets a first grader practice add

3、itions. The program randomly generates two single-digit integers and displays a question such as “What is 7 + 9?” to the student, as shown in Figure a. After the student types the answer in the input dialog box, the program displays a message dialog box to indicate whether the answer is true or fals

4、e, as shown in Figure b. (a) (b) (c) (d)NOTE: Write the program without using conditional statements. Use only the materials you learned in Chapter 2.(注:寫程序,無需使用條件語句。只使用你在第2章所學的材料。)Hint: Generate the random number using the System.currentTimeMillis() introduced in Chapter 2.提示:使用系統(tǒng)生成的隨機數(shù)。currenttime

5、millis()介紹2章。Submit the following items:1. Analysis: Restate the problem in your own words (e.g., what is input, output if any, what needs to be computed, what data needs to be stored and their type).1.分析:用自己的話重述問題(例如,什么是輸入,輸出,如果有,需要計算,哪些數(shù)據(jù)需要存儲和類型)。2. Design: Clearly describe the steps to solve this

6、 problem using English or pseudo code.2.設(shè)計:清晰地描述用英語或偽代碼來解決這個問題的步驟。3. Coding: Implement the solution in Java.4. Testing: Make sure that the numbers appear random. Submit the screen shots of two sample runs.4.測試:確保數(shù)字顯示隨機。提交兩個示例運行的屏幕截圖。Project #2 Tax Table (covers Chapter 3)CSCI 1301 Introduction to Pr

7、ogrammingArmstrong Atlantic State UniversityThe United States federal personal income tax is calculated based on filing status and taxable income. There are four filing statuses: single filers, married filing jointly, married filing separately, and head of household. The tax rates for 2005 are shown

8、 in Table (a)-(d). If you are, say, single with a taxable income of $10,000, the first $7,300 is taxed at 10% and the other $2,700 is taxed at 15%. So your tax is 730 + 2700 * 0.15.Schedule X SingleIf taxable income is  over-But not over-The tax is:$0$7,300730美元加15%的金額超過730010% of the

9、 amount over $0$7,300$29,700$730 plus 15% of the amount over 7,300$29,700$71,950$4,090.00 plus 25% of the amount over 29,700$71,950$150,150$14,652.50 plus 28% of the amount over 71,950$150,150$326,450$36,548.50 plus 33% of the amount over 150,150$326,450no limit$94,727.50 plus 35% of the amount over

10、 326,450 Schedule Y-1 Married Filing Jointly or Qualifying Widow(er)If taxable income is over-But not over-The tax is:$0$14,60010% of the amount over $0$14,600$59,400$1,460.00 plus 15% of the amount over 14,600$59,400$119,950$8,180 plus 25% of the amount over 59,400$119,950$182,800$23

11、,317.50 plus 28% of the amount over 119,950$182,800$326,450$40,915.50 plus 33% of the amount over 182,800$326,450no limit$88,320.00 plus 35% of the amount over 326,450 Schedule Y-2 Married Filing SeparatelyIf taxable income is over-But not over-The tax is:$0$7,30010% of the amoun

12、t over $0$7,300$29,700$730 plus 15% of the amount over 7,300$29,700$59,975$4,090 plus 25% of the amount over 29,700$59,975$91,400$11,658.75 plus 28% of the amount over 59,975$91,400$163,225$20,457.75 plus 33% of the amount over 91,400$163,225no limit$44,160.00 plus 35% of the amount o

13、ver 163,225 Schedule Z Head of HouseholdIf taxable income is over-But not over-The tax is:$0$10,45010% of the amount over $0$10,450$39,800$1,045 plus 15% of the amount over 10,450$39,800$102,800$5,447.50 plus 25% of the amount over 39,800$102,800$166,450$21,197.50 plus 28% o

14、f the amount over 102,800$166,450$326,450$39,019.50 plus 33% of the amount over 166,450$326,450no limit$91,819.50 plus 35% of the amount over 326,450Develop a program that prints a tax table for taxable income from $50,000 to $60,000 with intervals of $50 for all four statuses, as follows: 寫一個計

15、程序,打印應納稅所得稅表從50000美元到60000美元的所有四個狀態(tài)的50個區(qū)間taxableSingleMarried Married Head ofIncomeJoint Separate a House5000098467296 10398 85065005098597309 10411 8519.59950125329982 13190 1119260000125469996 13205 11206NOTE: the numbers in the preceding tax table are incorrect intentionally. You should print the

16、 correct values in the table.Submit the following items:1. Analysis: Restate the problem in your own words (e.g., what is input, output if any, what needs to be computed, what data needs to be stored and their type).2. Design: Clearly describe the steps to solve this problem using English or pseudo

17、code.3. Coding: Implement the solution in Java.4. Testing: Submit the screen shots for first 20 lines in the tax table.4.測試:在稅收表中提交前20行的屏幕截圖。Project #3 Least Common Multiple (covers Chapter 5)CSCI 1301 Introduction to ProgrammingArmstrong Atlantic State UniversityDefinition: The least common multipl

18、e (LCM) of two numbers is the smallest number that is a multiple of both. For example, the LCM for 8 and 12 is 24, for 15 and 25 is 75, and for 120 and 150 is 600. Develop a program that prompts the user to enter two integers and finds their least common multiple. 開發(fā)一個程序,提示用戶輸入兩個整數(shù),并找到它們的最小公倍數(shù)。To fi

19、nd the LCM of two numbers, first create a prime factor table for each number. The first column of the table consists of all the prime factors and the second column tracks the occurrence of the corresponding prime factor in the number. For example, the prime factors for 120 are 2, 2, 2, 3, 5, so the

20、prime factor table for number 120 is shown as follows: The prime factors for 150 are 2, 3, 5, 5, so the prime factor table for number 150 is shown as follows: The LCM of the two numbers consists of the factors with the largest occurrence in the two numbers. So the LCM for 120 and 150 is , where 2 ap

21、pears three times in 120, 3 one time in 120, and 5 two times in 150.Submit the following items:1. Analysis: Restate the problem in your own words (e.g., what is input, output if any, what needs to be computed, what data needs to be stored and their type).2. Design: Clearly describe the steps to solv

22、e this problem using English or pseudo code. (Hint: The prime factor table can be represented using a two-dimensional array. Write a method named getPrimeFactors(int number) that returns a two-dimensional array for the prime factor table.)(提示:可以使用一個二維數(shù)組表示素因子表。寫一個方法叫g(shù)etprimefact OR(int數(shù)),返回的素因子表的二維數(shù)組

23、。)3. Coding: Implement the solution in Java. 4. Testing: Test your program to find the LCM for (120, 150), (7, 14), (7, 8), (1, 2), and (345, 455)Project #4 Design Classes (covers Chapter 6)CSCI 1302 Introduction to ProgrammingArmstrong Atlantic State UniversityThis project consists of two separate

24、problems. 1. Design a class named Rectangle to represent a rectangle. The class contains: · Two double data fields named width and height that specify the width and height of the rectangle. The default values are 1 for both width and height.· A string data field named color that specifies

25、the color of a rectangle. Hypothetically, assume that all rectangles have the same color. The default color is white.· A no-arg constructor that creates a default rectangle.沒有參數(shù)的構(gòu)造函數(shù),創(chuàng)建一個默認的矩形。· A constructor that creates a rectangle with the specified width and height.創(chuàng)建一個具有指定寬度和高度的矩形的構(gòu)造函

26、數(shù)· The accessor and mutator methods for all three data fields. 所有三個數(shù)據(jù)字段的訪問器方法。· A method named getArea() that returns the area of this rectangle.一種getarea()返回這個矩形的面積。· A method named getPerimeter() that returns the perimeter.一種getperimeter()返回周長。Draw the UML diagram for the class. Imp

27、lement the class. 這類畫UML圖。實現(xiàn)類。Write a test program that creates two Rectangle objects. Assign width 4 and height 40 to the first object and width 3.5 and height 35.9 to the second object. Assign color red to all Rectangle objects. Display the properties of both objects and find their areas and perim

28、eters.編寫一個創(chuàng)建兩個矩形對象的測試程序。分配寬度4和高度40到第一個對象和寬度3.5和高度35.9到第二個對象。將顏色分配給所有矩形對象。 顯示的對象的屬性,找到他們的周長和面積。2. Design a class named Time. The class contains: · Data fields hour, minute, and second that represents a time.· A no-arg constructor that creates a Time object for the current time. (The data fi

29、elds value will represent the current time)在沒有參數(shù)的構(gòu)造函數(shù)中創(chuàng)建時間為當前時間對象.(數(shù)據(jù)值將代表當前時間)· A constructor that constructs a Time object with a specified elapse time since the middle night, Jan 1, 1970 in milliseconds. (The data fields value will represent this time)一個構(gòu)造函數(shù)構(gòu)造一個時間與指定的時間從半夜對象,1970年1月1日在毫秒。(數(shù)據(jù)字段值將代表這段時間)· Three get methods for the data fields hour, minute, and second, respe

溫馨提示

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

評論

0/150

提交評論