星期四, 12月 25, 2008

Quiz 12-26-2008

1. Design a non-static method that can compute the addition of fractions. You must first define Fraction class then write a demo program to verify the class program.

2. Design a static method that can compute the addition of fractions. You must first define Fraction class then write a demo program to verify the class program.

3. 列舉至少三個Java程式的風格

4. 列舉至少三個Java記憶體管理的特性

5. Write a Java program to solve the Hanoi Tower Problem.

6. Write a Java program to solve the Hanoi Tower Problem.

7. Explain ADT (Abstract Data Type).

8. Explain API (Application Programming Interface).

9. Write a Java program to calculate the sin function as follows:
sin(x)=x - x 3/3! + x5/5! - x7/7! ...

10. Write a Java program to calculate the cosine function as follows:
Cos(x)=1 - x 2 /2!+ x 4/4!- x 6/6!...

11. 一個Java 物件使用多少個Byte記憶體? 為什麼?

12. 請解釋 Garbage Collector 的作用。試舉例說明。

13. 請解釋 Overloading ,舉例說明何時可能會用到 Overloading

14. 請解釋 Constructor ,舉例說明何時可能會用到 Constructor

星期五, 12月 19, 2008

Lab Hanoi Tower

The pseudocode for Hanoi Tower is as follows:

solve(N, Src, Aux, Dst)
if N is 0 return
solve(N-1, Src, Dst, Aux)
Move N from Src to Dst
solve(N-1, Aux, Src, Dst)


Write the Java program based on the pseudocode in the above.

Lab Factorial

Write a Java program that computes N! where N is a positive integer.

Hint:

public static long factorial(int n)

Lab Recursive Method

Write a recursive method to compute Fibonacci series.

Hint:

1.
fib(n)=fib(n-1)+fib(n-2)

2.
public static long fib(int n)

星期四, 12月 18, 2008

我有話要說

如果你覺得這學期Java 功課表現尚不滿意,你可以在部落格上自由發揮,用你覺得比較好的方式告訴別人,其實我已經學好 Java ,我會閱讀你所書寫。

星期五, 12月 12, 2008

Quiz 2: 12/26/2008

Format: closed book
Running time: 45 min.
Scope: Chap.4~Chap. 5, Chap. 11

Lab Static Method

Define a Complex class with a static method for computing complex addition. Use (2+3i)+(4+5i) in your test.

Lab Java Constructor

Use Display 4.14 to call 4.13 (2nd ed.) or
Display 4.12 to call 4.11 (1st ed.).

After you finish the above, try the following

Date birthday = new Date("Jan",1,2000);
birthday.Date("Feb",1,2000);
birthday.setDate("Feb",1,2000);
birthday=new Date("Mar",1,2000);

星期六, 11月 29, 2008

11月30日『飛行少年』電影

飛行少年,是腳踩單輪車,爬上平均斜率45度的八公里鐵人坡,ㄧ群年齡7-17歲的失養孩子或徬徨少年。

活動內容

星期四, 11月 27, 2008

行動科技輔具冬令營 報名

有興趣找我做專題同學,請參閱大學部專題特區。我們會先在1/16/2009 舉辦行動科技輔具冬令營隊,介紹專題內容與基礎能力。有興趣者,請自行組成專題團隊。

本次招收10位同學,若干團隊(每隊2人),冬令營活動結束後,將進行個別團隊洽談。

報名行動科技輔具冬令營者,即日起請登記

Lab Overloading

Do Display 4.11

Lab ADT

Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.
The methods should include an access and a mutator.

Quiz 2: 12/26/2008

Format: closed book
Running time: 45 min.
Scope: Chap.4~Chap. 5

星期二, 11月 25, 2008

Dec 5, 2008 上課暫停一次

NST 2008 發表論文。

2009 新課程: 先進網際服務系統

適合大三以上,對網際網路服務原理與各式應用有高度興趣者。詳細課程請參閱課程大綱

星期五, 11月 21, 2008

Homework 11-21-2008

11月30日『飛行少年』電影

飛行少年,是腳踩單輪車,爬上平均斜率45度的八公里鐵人坡,ㄧ群年齡7-17歲的失養孩子或徬徨少年。

活動內容

lab Fraction equality test

Write a program to implement a method that can check whether 2 fractions are equal. You will implement a class called Fraction consisting of a numerator and a denominator. The equality test of 2 fractions should return a boolean value.

Use the following as the tests.

  • 1/2, 2/4
  • 5/6, 6/7

Hints:
Fraction f1, f2;
f1.equals(f2);

lab Fraction Addition

Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator. The additions of
2 fractions should be equal to a fraction.
Use 1/2+1/3 as the test.

Hints:
Fraction f1, f2;
f1.add(f2);

Class Definition 3

Do Display 4.7 (3rd, 2nd ed.) or 4.5 (1st ed.). Then use Display 4.8 to call 4.7.

Question
In Display 4.7, if the method setDate has the parameter as setDate(int month, int day, int year), what kind of changes should be made in its body of codes?

星期三, 11月 19, 2008

大三專題指導

有興趣找我做專題同學,請參閱大學部專題特區。我們會先在1/16/2009 舉辦行動科技輔具冬令營隊,介紹專題內容與基礎能力。有興趣者,請自行組成專題團隊。

本次招收10位同學,若干團隊(每隊2人),冬令營活動結束後,將進行個別團隊洽談。

星期一, 11月 17, 2008

星期五, 10月 31, 2008

Homework 10-31-2008

Study Display 4.1 and then do Self-Test Exercise 1.

Answer to Quiz

1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x 4- 6!/x 6...

double power=1, fact=1, sum=0;
int k=-1;

for(int i=1; i<10; i++)
{
power=power*x;
fact=fact*i;
if(i%2==1)
{ k=k*(-1);
sum+=k*power/fact;
}
}


6. Write a complete Java program that uses a for loop to compute the sum of odd numbers between 1 and 25.

int evenSum=oddSum=0;

for(i=1; i<=25; i++)
{
if(i%2!=0)

oddSum+=i;

}

lab class definition 2

Study Display 4.4 (2nd ed. and 3rd ed.) or Display 4.2 & Display 4.3 (1st ed.) and then
1. Comment out date.setDate(6, 17, year); by // date.setDate(6, 17, year);
2. At the next line below, add date.readInput();
3. Run the program again. Fix any problems you may encouter along the way.
4. At the last line of your program, add System.out.println(date.month);
and see what happens. Why?

lab counter

Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test


counter.reset();
counter.inc();
counter.inc();
counter.dec();
counter.output();

Quiz 10-31-2008

1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x 4- 6!/x 6...

2. Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...

3. Write a Java program that can determine the minimum of any 4 numbers.

4. Write a Java program that can determine the maximum of any 4 numbers.

5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.

6. Write a complete Java program that uses a for loop to compute the sum of the odd numbers between 1 and 25.

7. Explain syntax errors and sematic errors.

8. Explain programming styles and naming conventions in Java.

9. What is Java Virtual Machine and Java Bytecode?

10. Explain Java's feature "Write once, run anywhere."

星期五, 10月 24, 2008

Homework 10-24-2008

1. Write a program to generate the series 1, 1, 2, 3, 5, 8, 13, ...
The series has a property that the third number is the sum of the first and second numbers. For example, 2=1+1, 3=1+2, and 5=2+3.

2. Write a program to generate the following table of arithmetic expressions

1*1=1 1*2=2 1*3=3 ... 1*9=9
2*1=2 2*2=4 2*3=6 ... 2*9=19
...
9*1=9 9*2=18 9*3=27 ... 9*9=81


參觀老師的新蘇格蘭遊記

10-31-2008 小考

範圍: Chap 1~3
可攜帶: 課本,一張A4筆記,計算機

Lab Finding the max of a list of numbers

Based on your study of Display 3.8, write a code to find the max and min of a list of number.
For example, given 1,3,5, and9, the max is 9 and the min is 1.
Your program should be able to process a list of any length.

Lab Finding the max of three numbers

Write a program to decide the max number of the three input number.

Lab: Tax Calculation

Study Display 3.1. Based on the income tax rate in Taiwan,
calculate the income tax of a person whose annual income is 1,000,000 or 2,000,000.

星期五, 10月 03, 2008

Homework 10-3-2008

1. Complete Lab Keyboad processing
3. Do Project 4 in Chapter 2
4. Do Project 5 in Chapter 2
5. Do Project 6, in Chapter 2
6. Do Project 7, in Chapter 2

Due 10/24/2008 13:00

Lab: 增加回應功能

1. 以一段程式自動擷取部落格的回應留言,讓你的部落格產生最新回應,沒有時差。
2. 請你的同學給你一個 comment,是否能正確顯示在最新回應上。
3. 實例

Lab: Numerical Method

Project 1 of Chap. 2.

Lab Keyboad processing

Project 3 of Chap. 2.

Lab Keyboard Input

Rewrite Display 2.6 using BufferedReader.

You need to import the following packages in the first place.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

Change

Scanner keyboard= new Scanner(System.in);

into

BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));

String inputString = keyboard.readLine();

Note the Main method needs IOException handling as follows:

public static void main (String[] args) throws IOException

Lab Scanner

Do Display 2.6.

What is ASCII?

星期三, 10月 01, 2008

Notice

10月10日Java課程,暫停壹次。(國定假日)
10月17日Java課程,暫停壹次。

I will present papers at ACM ASSETS 2008 in Halifax, Canada.

星期五, 9月 26, 2008

Homework 9-26-2008

1. Complete Lab String Processing.
2. Write a program that can reverse the order of an input string. For example, if you input "ab", it will output "ba". If you input "abcdefg", it should return "gfedcba".

Lab: String Processing

Do Project 5 of Chap. 1 on Page 56.

Write a program that starts with a line of text and then outputs that line of text with the first occurrence of "hate" changed to "love". For example, a possible sample output might be

The line of text to be changed is:
I hate you.
I have rephrased that line to read:
I love you.

Hint: You may consider use the methods: indexOf(A_String) and substring(Start, End) in your program.

Lab: Simple Arithmetics

Write a Java program that displays the results of the expressions 15/4, 4/15, 15%4, 4%15. Calculate the values of these expressions manually to verify that the displayed values are correct.

Lab: Simple Calculation

Suppose you are a landscape architect who charges $5,000 per mile to landscape a highway, and suppose you know the length in feet of the high way you are working on. Write a Java program to calculate the price you charge when the length is 6000 and 4000, respectively.

Hint: There are 5280 feet in a mile.

星期五, 9月 19, 2008

Lab: Get familiar with JBuilder

Do Display 1.1

建議你同時使用畫面與文字呈現你的執行結果。參考範例

Homework 9-19-2008

Due 9/26/2008 at 13:00

"tell me and I'll forget; show me and I may remember; involve me and I'll understand"

1. Explain bytecode, JVM
2. Explain class, object
3. Reading Assignments:
Read 1.1, 1.2, 1.3 of Textbook

4.1 Write a Java program as follows:

Let i=2;
Print i;
Print 2 * (i++);
Print i;

Ans: 2, 4, 3

4.2 Write a Java program as follows:

Let i=2;
Print i;
Print 2 * (++i);
Print i;

Ans: 2, 6, 3

4.3 Write a Java program as follows:

Let m=7, n=2;
Print (double) m/n;
Print m/ (double)n;

Ans: 3.5, 3.5

Lab 2: Java for Scientific Computation

Do Project 4 on Page 55. (3rd Edition)

Do Project 4 on Page 56. (2nd Edition)

Do Project 1 on Page 54. (1st Edition)

artificial sweetener 人工代糖(過量可以致癌)
diet soda pop 減肥可樂
lose weight 減肥

星期四, 9月 11, 2008

Let's start blogging

1. 至 http://www.blogger.com 申請, 請以你的學號 (s開頭) 申請免費帳號。

2. 張貼你的部落格的第一篇文章。一小段歡迎詞,或是簡短自我介紹,或是你最喜歡的事物與最不喜歡的事物,都可以。

3. 建立一個連結到課程網站 http://javaatcycu.blogspot.com/
建議你使用右上角"自訂"功能,新增一個區塊。一個區塊內可以置放多個連結。

4. 日後請將你的隨堂練習與作業寫在你的 blog, 然後到
Homework 或 Lab 的Comment 登錄作業blog網址就可以了.
請勿將整個作業直接寫在老師部落格的Comment處。

5. 尊重智慧財產權,引用他人文章須註明出處。並且應該合乎學術常規,以合理的方式引用。

注意事項

a. blog需正確設定時區顯示時間 。
b. 請測試他人可否留言(comment)。以方便留下回應意見。

tip

How to insert a link at the following comment, please use the following HTML code.

2008 春季成績分布

星期一, 6月 16, 2008

Quiz 4  成績

List of those who did not pass, with scores less than 1/2
9326361
9226119
9426261
9526202
9526208
9526150
9526350
9526248
9426235
9526349

中原大學電子系輔具科技夏令營 2008

你想過你正在學的電子專業可以為弱勢的人服務嗎?你想多了解無線行動運算與服務運算最新趨勢嗎?

邀請熱情的妳/你參加中原大學電子系輔具科技夏令營 2008,結合先端科技為弱勢服務,就從這裡開始。

報名:請在意見區寫上姓名即可。

Quiz 4

1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...

2. Write a Java program to calculate the sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...

3. Design a non-static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.

4. Design a static method that can compute the product of complex numbers. You must first define Complex class then write a demo program to verify the class program.

5. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.

6. Write a complete Java program that uses a for loop to compute the sum of the even numbers between 1 and 25.

7. Explain API and ADT.

8. Explain programming styles and naming conventions

星期一, 6月 09, 2008

Lab Magic Parking Tower

A parking tower is out of order someday. If you park a Benz, you will end up with a Torben. Write a program to simulate this scenario. First create a class called CarParked which has a static method called outOfOrder. Name an object called yourCar, which happens to be a Benz. Your program should contain a class called CarParked and a test program called CarParkedDemo which test the method by CarParked.outOfOrder(yourCar).

Hint: You may study Display 5.14 to get some ideas.

Lab Static method

Define a Complex class with a static method for computing complex addition. Use (2+3i)+(4+5i) in your test.

Last Quiz 6/16

Format: closed book
Running time: 45 min.
Scope: Chap.1~Chap. 5

歷屆試題

期末報告

到圖書館挑選二本Java課本,寫下這些書名與作者出版社與出版日期,每本書各挑選一個習題進行個人研究,說明以下

  • 你為什麼挑選這個習題(只有題目,沒有範例或解答),
  • 這個習題讓你學到什麼概念,
  • 請你製作一個講義說明這個習題。


Due: 6/29/2008 at 18:00

程式 & 生涯

國外公司如微軟,Google應徵新人會考程式,國內手機, NB, GPS大廠其實也類似,最近我們的學生找Firmware Engineer工作,臨時被考程式能力。有些研究所的甄試在複試時也是當場測驗程式。

人不是生下來就會寫程式,所以具備熱情去學習在我看來是最重要的了,事實上,不只是寫程式,熱情已經是專業的一部份,我們常常可以在專業的表現中看到人們所投注的熱情。有興趣可以參考我的部落格寫程式熱情

我有話要說

如果你覺得這學期Java 功課表現尚不滿意,你可以在部落格上自由發揮,用你覺得比較好的方式告訴別人,其實我已經學好 Java ,我會閱讀你所書寫。

前人告白

本學期最後兩次上課

  • 可能會加強點名
  • 將登記未攜帶課本者,作為平時分數參考。

Homework due 6/16/2008

Enter

星期五, 6月 06, 2008

叮嚀

使用正版教科書,勿非法影印書籍及教材,以免侵犯他人著作權

星期二, 6月 03, 2008

作業與Lab成績

作業缺少ㄧ次扣Homework 總分5分
Lab 缺少ㄧ次扣Lab 總分3分

總成績配分方式

6/9 請攜帶課本

將登記未攜帶課本者,作為平時分數參考。

小考至少兩次不及格且至少ㄧ次0分

9526202
9526208
9526214
9526232

9526150
9326361
9226119

Quiz 3

通過名單

9527118
9527129
9527158

9526238
9526240
9526261
9526319
9526350
9526353
9426231
9326263
9325120
9325146
方彥順

Quiz 6-16-2008

Format: closed book
Running time: 45 min.
Scope: Chap.1~Chap. 5

歷屆試題

Homework 6-02-2008

第二次隨堂測驗中答錯的項目重做。

星期一, 6月 02, 2008

Lab Java Constructor

Use Display 4.14 to call 4.13 (2nd ed.) or
Display 4.12 to call 4.11 (1st ed.).

After you finish the above, try the following

Date birthday = new Date("Jan",1,2000);
birthday.Date("Feb",1,2000);
birthday.setDate("Feb",1,2000);
birthday=new Date("Mar",1,2000);

Quiz 6-2

1. Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1.

2. Define a Complex class with complex addition.

3. What is Abstract Data Type (ADT)?

4. What is "Overloading"? Why is it useful?

5. Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator.

6. Design a method that can compute the vector inner product. You must define Vector class in the first place. Write a demo program to verify your program works.

星期一, 5月 26, 2008

Lab Overloading

Do Display 4.11

Lab ADT, accessor, mutator

Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.
The methods should include an access and a mutator.

Quiz 3: Jun-2-2008

Format: closed book
Running time: 30 min.
Scope: Chap. 4

星期一, 5月 19, 2008

Homework 5-19-2008

1. Do Temperature Project, which is Project 7 (3rd, 2nd ed.) or Project 3 (1st ed.).

lab Fraction equality test

Write a program to implement a method that can check whether 2 fractions are equal. You will implement a class called Fraction consisting of a numerator and a denominator. The equality test of 2 fractions should return a boolean value.

Use the following as the tests.

  • 1/2, 2/4
  • 5/6, 6/7

Hints:
Fraction f1, f2;
f1.equals(f2);

lab Fraction Addition

Write a program to implement a method that can do additions of 2 fractions. You will implement a class called Fraction consisting of a numerator and a denominator. The additions of
2 fractions should be equal to a fraction.
Use 1/2+1/3 as the test.

Hints:
Fraction f1, f2;
f1.add(f2);

老師的希臘之行

進入

星期一, 4月 28, 2008

No classes on May 5 and May 12

I am presenting 2 papers at IEEE ISWPC, Santorini, Greece. Therefore, there will be no class on May 5 & May 12.

Conference dates: May 7~9, 2008

Trip to WWW2008, Beijing, Apr 20~Apr 26

Link to YJ Chang's blog

Homework 4-28-2008

lab counter

lab class definition 3

lab counter

Define a class called Counter whose objects count things. An object of this class records a count that is a nonnegative integer. Include methods to set the counter to 0, to increase the count by 1, and to decrease the count by 1. Include an accessor method that returns the current count value and a method that outputs the count to the screen. Write a program to test


counter.reset();
counter.inc();
counter.inc();
counter.dec();
counter.output();

Class Definition 3

Do Display 4.7 (3rd, 2nd ed.) or 4.5 (1st ed.). Then use Display 4.8 to call 4.7.

Question
In Display 4.7, if the method setDate has the parameter as setDate(int month, int day, int year), what kind of changes should be made in its body of codes?

lab class definition 2

Study Display 4.4 (2nd ed. and 3rd ed.) or Display 4.2 & Display 4.3 (1st ed.) and then
1. Comment out date.setDate(6, 17, year); by // date.setDate(6, 17, year);
2. At the next line below, add date.readInput();
3. Run the program again. Fix any problems you may encouter along the way.
4. At the last line of your program, add System.out.println(date.month);
and see what happens. Why?

星期一, 4月 14, 2008

4-21-2004 不上課

Due to the midterm week, we will not meet on Apr. 21. Wish you good luck!

ps. 4-21-2008 沒有 homework.

Partial Answer to Quiz 2

Partial solutions: The following solutions are not complete Java programs. They are kept brief to illustrate the main ideas of the complete programs.

Problem 1:

1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...

double power=1, fact=1, sum=0;
int k=-1;

for(int i=1; i<10; i++)
{
power=power*x;
fact=fact*i;
if(i%2==1)
{ k=k*(-1);
sum+=k*power/fact;
}
}


Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 50.

int evenSum=oddSum=0;

for(i=1; i<=50; i++)
{
if(i%2==0)
evenSum=evenSum+i;
else
oddSum+=i;

}

lab class definition

Study Display 4.1 and then do Self-Test Exercise 1.

Quiz 4-14-2008

There are 3 problem each with its own marks. Total above 75 marks is considered as PASS.

1. (50) Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x4 - 6!/x6 ...

2. (30)

Write a complete Java program that uses a for loop to compute the sum of the even numbers and the sum of the odd numbers between 1 and 50.

3. (20) Rewrite the following for loop using a while expression.

int Sum=0;
for(i=0; i<=10; i++)
Sum=Sum+i;

星期一, 4月 07, 2008

Quiz 2: 4-14-2008

Format: closed book
Running time: 30 min.
Scope: Chap. 3

Average income by gender

Write a program to calculate average income by gender based on the following data, where F stands for female and M for male.

F 62,000
M 25,000
F 38,000
F 43,000
M 65,000
M 120,000
F 80,000
M 30,100

You should be able to allow users to type in a whole line such as F 80,000 followed by next line M 30,100.

Without any change made to your program, your program should be able to process a new set of data, such as follows:

M 52,000
M 35,000
F 48,000
M 33,000
F 75,000
F 110,000
F 90,000
M 30,100

Lab 9*9

Write a program to generate the following table of arithmetic expressions

1*1=1 1*2=2 1*3=3 ... 1*9=9
2*1=2 2*2=4 2*3=6 ... 2*9=19
...
9*1=9 9*2=18 9*3=27 ... 9*9=81

Lab Fibonacci numbers

Do Project 3.3 (1st ed.) or Project 6 (2nd ed. & 3rd ed.) Fibonacci numbers.
List the first 100 numbers and the ratio of
a number to its previous number, such as 1/1 = 1, 2/1 = 2, 3/2 = 1·5, 5/3 = 1·666..., 8/5 = 1·6, 13/8 = 1·625, 21/13 = 1·61538....

Want to know more about Fibonacci number

星期一, 3月 24, 2008

Homework 3-24-2008

1. Based on your study of Display 3.8, write a code to find the max and min of a list of number.
For example, given 1,3,5, and9, the max is 9 and the min is 1.
Your program should be able to process a list of any length.

2. Write a program to generate the series 1, 1, 2, 3, 5, 8, 13, ...
The series has a property that the third number is the sum of the first and second numbers. For example, 2=1+1, 3=1+2, and 5=2+3.

Lab Finding the max of three numbers

Write a program to decide the max number of the three input number.

Lab: Tax Calculation

Study Display 3.1. Based on the income tax rate in Taiwan,
calculate the income tax of a person whose annual income is 1,000,000 or 2,000,000.

Quiz 3-24-2008

1. Let i, j be two integers. Write a Java program to exchange their values. Please make sure you have good styles of making comments, naming variables, and indenting.

2. The identifier StreamReader is normally abbreviated as SR in programming language C. However, Java programmers normally do not use abbreviations for identifiers. What are the advantages and disadvantages of not using abbreviations?

3. a. What is "self-documenting"?
b. What is the purpose of "Unicode"? Does Java use it?

4. Give an example of "logic error"

星期一, 3月 17, 2008

Quiz 1: 3-24-2008

Format: closed book
Running time: 30 min.
Scope: Chap. 1

Homework 3-17-2008

Lab: Keyboard Input
Project 1 of Chap. 2.
Project 3 of Chap. 2.

Lab Keyboard input

Rewrite Display 2.6 using BufferedReader.

You need to import the following packages in the first place.

import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

Change

Scanner keyboard= new Scanner(System.in);

into

BufferedReader keyboard= new BufferedReader(new InputStreamReader(System.in));

String inputString = keyboard.readLine();

Note the Main method needs IOException handling as follows:

public static void main (String[] args) throws IOException

Lab Scanner

Do Display 2.6.

星期一, 3月 10, 2008

Homework 3-10-2008: String Processing

Do Project 5 of Chap. 1 on Page 56.

Write a program that starts with a line of text and then outputs that line of text with the first occurrence of "hate" changed to "love". For example, a possible sample output might be

The line of text to be changed is:
I hate you.
I have rephrased that line to read:
I love you.

Hint: You may consider use the methods: indexOf(A_String) and substring(Start, End) in your program.

請務必攜帶課本

  • 從 3/ 17 開始,將開始登記未攜帶課本者,同用一桌者至少須有ㄧ本。版本不拘。新舊皆可。
  • 尊重智慧財產,不可使用影印本。

Lab: Simple Calculation

Suppose you are a landscape architect who charges $5,000 per mile to landscape a highway, and suppose you know the length in feet of the high way you are working on. Write a Java program to calculate the price you charge when the length is 6000 and 4000, respectively.

Hint: There are 5280 feet in a mile.

星期一, 3月 03, 2008

Homework 3-3-2008

Due 3/10/2008 at 18:50

"tell me and I'll forget; show me and I may remember; involve me and I'll understand"

1. Explain bytecode, JVM
2. Explain class, object
3. Reading Assignments:
Read 1.1, 1.2, 1.3 of Textbook

4.1 Write a Java program as follows:

Let i=2;
Print i;
Print 2 * (i++);
Print i;

Ans: 2, 4, 3

4.2 Write a Java program as follows:

Let i=2;
Print i;
Print 2 * (++i);
Print i;

Ans: 2, 6, 3

4.3 Write a Java program as follows:

Let m=7, n=2;
Print (double) m/n;
Print m/ (double)n;

Ans: 3.5, 3.5

Lab 2 Java for Scientific Computation

Do Project 4 on Page 55. (3rd Edition)

Do Project 4 on Page 56. (2nd Edition)

Do Project 1 on Page 54. (1st Edition)

artificial sweetener 人工代糖(過量可以致癌)
diet soda pop 減肥可樂
lose weight 減肥

Lab Get familiar with JBuilder

Do Display 1.1

星期一, 2月 25, 2008

Homework 2-25-2008

Due 3/3/2008 at 18:50

1. Watch The Inside Story (Video), write your words on the development and inventor of Java.
2. List at least 5 applications of Java. You must provide the references you used. We recommend Google Search engine.

ps.

Lab: Start Blogging

1. 至 http://www.blogger.com 申請, 請以你的學號 (s開頭) 申請免費帳號。

2. 張貼你的部落格的第一篇文章。一小段歡迎詞,或是簡短自我介紹,或是你最喜歡的事物與最不喜歡的事物,都可以。

3. 日後請將你的隨堂練習與作業寫在你的 blog, 然後到
Homework 或 Lab 的Comment 登錄作業blog網址就可以了.
請勿將整個作業直接寫在老師部落格的Comment處。

4. 尊重智慧財產權,引用他人文章須註明出處。並且應該合乎學術常規,以合理的方式引用。

注意事項

a. blog需正確設定時區顯示時間 。
b. 請測試他人可否留言(comment)。以方便留下回應意見。

tip

How to insert a link at the following comment, please use the following HTML code.

星期二, 1月 15, 2008

星期五, 1月 11, 2008

Lab Hanoi Tower

The pseudocode for Hanoi Tower is as follows:

Solve(N, Src, Aux, Dst)
if N is 0 return
Solve(N-1, Src, Dst, Aux)
Move N from Src to Dst
Solve(N-1, Aux, Src, Dst)


Write the Java program based on the pseudocode in the above.

Lab Factorial

Write a Java program that computes N! where N is a positive integer.

Hint:

public static long factorial(int n)

lab recursive method

Write a recursive method to compute Fibonacci series.

Hint:

fib(n)=fib(n-1)+fib(n-2)

星期五, 1月 04, 2008

Bonus: Modular Sorting

Write a sort method which takes a double array as parameter
and returns the sorted array. Call this method in a main program.

Hint: The lab is a rewriting of Lab Sorting
to make the sorting procedure a reusable method.

星期四, 1月 03, 2008

Lab Array

Study Display 6.1, and then write a program that can sort numbers in ascending order.

網路安全

學校的公用電腦有可能被植入木馬程式,因此你的帳號密碼可能已經被木馬程式紀錄並且流出,這些駭客集團會到各網站逐一測試你所流出的帳號密碼,如果你常使用的網站用的是同ㄧ組帳號密碼,那麼你在其他網站的個人資料也可能被入侵流出。
最近不少知名網站被駭客入侵,個人資料外洩日益頻繁。因此建議你儘速找一台沒有被植入木馬程式的電腦,更改你重要網站的密碼。

星期三, 1月 02, 2008

Lab Magic Parking Tower

A parking tower is out of order someday. If you park a Benz, you will end up with a Torben. Write a program to simulate this scenario. First create a class called CarParked which has a static method called outOfOrder. Name an object called yourCar, which happens to be a Benz. Your program should contain a class called CarParked and a test program called CarParkedDemo which test the method by CarParked.outOfOrder(yourCar).

Hint: You may study Display 5.14 to get some ideas.

我有話要說

如果你覺得這學期Java 功課表現尚不滿意,你可以在部落格上自由發揮,用你覺得比較好的方式告訴別人,其實我學好 Java 。期末評分時,我會閱讀你所書寫。