星期六, 12月 29, 2007

勤練程式

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

期末報告題目

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

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


Due: 1/11/2008 at 18:00

星期五, 12月 28, 2007

Lab: Static Method II

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

星期五, 12月 21, 2007

觀摩學習

這位同學為了鼓勵讀者留言,寫了"你的回應 我的動力"在回應區上,很不錯的點子。

Homework 12/21/2007

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. You should use constructors to initialize the two vectors.

Hint: The inner product is not a vector. It is a number (scalar).

Sample answer

Lab Static Method

Study Display 5.2.
Using static variables and static methods to implement the class Fibonacci such that
the first call to Fibonacci.next()
returns 2, the second returns 3, and then 5, and so on.

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);

星期六, 12月 08, 2007

Quiz on Chap. 4

1. Explain API and ADT.
2. How are the object variables managed by Java compilers? Are they managed in the same way as variables of primitive types?
3. In the following statement,

Date myDate= new Date();

What is the use of "new"?

4. 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. 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

星期五, 12月 07, 2007

Solution to Faction addition

public class Fraction
{
private int Numer,Denom;

public Fraction ()
{
}

public Fraction (int Numer, int Denom)
{
this.Numer = Numer;
this.Denom = Denom;
}

public void setNumber(int Numer, int Denom)
{
this.Numer = Numer;
this.Denom = Denom;
}

public String toString()
{
return (Numer + " /" + Denom);
}

public static void add(Fraction c1,Fraction c2)
{
Fraction number = new Fraction();

number.Numer= (c1.Numer*c2.Denom) + (c2.Numer*c1.Denom);
number.Denom = c1.Denom * c2.Denom;

return number;
}

public void writeOutput()
{
System.out.println(Numer + " / " + Denom);
}
}

Quiz 3: 12-14-2007

Java 基本知識,問答題 50%, 範圍課本 Chap. 4.1~4.2, Open book
Java 物件導向程式設計,50%, 範圍課本 Chap. 4.1~4.2, Open book

Format: written test, no computers

Homework 12-7-2007

1. Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.

2. Show comments on your blog.

Show comments on your blog

以一段程式自動擷取部落格的回應留言,讓你的部落格產生最新回應,沒有時差。

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);

星期五, 11月 30, 2007

Homework 11-30-2007

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

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?

星期五, 11月 16, 2007

Homework 11/16/2007: 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 class definition

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

態度決定高度

得知有同學回家是不看Java,也沒有課本,
只有上課時來抄襲旁人的作業,在此只好明說,這門課不是 All-Pass。
上學期有八人因為知道無法及格,於期末退掉這門課,
整學期的努力最後必須退掉並不值得鼓勵。

另外對於不少人非常認真想學好Java,尤其是過去沒有電腦程式基礎的同學,無論前兩次小考結果如何,老師都要給你們鼓勵,欣賞你們用心的態度。

祝大家期中考有好的表現,也隨時照顧好自己。

星期五, 11月 09, 2007

Makeup Work 11/9/2007

第二次小考未通過者,你可以使用JBuilder 重做全部三個題目,學期末將參酌加分。最慢繳交日期 11/25。
尤其前兩次小考都未通過者,這個加分將加在佔總分40%的平時分數裡面。

For those who didn't pass Quiz II (see the list), you are encouraged to write complete Java programs and run them on your JBuilder. Please present your source codes and the answers that your programs produce.

Your makeup work can be posted to the following comment area, as usual.

Partial Solutions to Quiz II

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:

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;
}
}


Problem 2:

int evenSum=oddSum=0;

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

}

Perforamnce Alert (didn't pass either Quiz 1 or Quiz 2)

9325121
9326206
9326223
9326246
9326251
9326256
9326268
9326309
9326314
9426113
9426114
9426130
9426224
9426228
9426236
9426332
9426365
9441142
9441210
9442234

Quiz 11/9/2007: Result

PASS
9326125 (100/150)
9326227 (100/150)
9426106 (100/150)
9426147 (80/150)
9426202 (120/150)
9426212 (125/150)
9426214 (75/150)
9426352 (150/150)
9426364 (150/150)

No PASS:
9325121
9326206
9326222
9326223
9326246
9326251
9326256
9326268
9326309
9326314
9326315
9426113
9426114
9426130
9426208
9426219
9426224
9426228
9426236
9426324
9426332 (No show)
9426365
9441142
9441210
9442234
9444162

Quiz 11/9/2007

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 sin function as follows:
sin(x)=x - 3!/x 3 + 5!/x5 - 7!/x7 ...

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 25.

3. (70) Write a program to calculate average science scores by gender based on the following data, where F stands for female and M for male.

M 82
M 65
F 88
M 63
F 75
F 90
F 90
M 70

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




星期五, 10月 26, 2007

Homework 10-26-2007

Lab Exponential Function

Lab average income by gender

Advance notice

Lab Exponential Function

Do Project 7 of Chap. 3. (2nd ed. & 3rd ed.) or Project 4 (1st ed.)

Hint: You don't have to use nested loops.

11-9-2007 Quiz 2

Scope: Chap 3
Format: Open book. Pencil & Paper.
Running time: 30 min.

預告: 11/23 期中考週不上課。

作業遲交

電子四丙9326314簡康祐

星期五, 十月 26, 2007 1:10:00 下午


9326268 李致學

星期五, 十月 26, 2007 2:07:00 下午


電子三乙9426236林庭輝

星期五, 十月 26, 2007 2:08:00 下午

ASSETS 2007 心得見聞分享

參加ACM ASSETS 2007回應出奇的好

母音與音調的妙用

聽人的語文是聽障者的第二語言

ASSETS 2007 ㄧ位女士的話

ACM ASSETS 2007 後記

鳳凰城動物園遊記

11-2-2007

老師請公假到美國參加ACM Web Intelligence會議發表論文,暫停課程一次。

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

星期五, 10月 12, 2007

Homework 10-12-2007: Finding the max and the min

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.

Bonus: Lab for-loop

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.

Quiz 10-12-2007 pass list

電子三丙9426364張家瑜
資管三甲 9444162 陳怡如
電子三乙 9426208 黃韋翔
電子三乙9426212黃嘉弘
電子三丙9426352陳彥儒
電子三甲 9426106 周家汝
電子四乙9326227彭書敏
電子三乙9426202蘇柏寬
電子三丙9426324詹敬翔
電子三乙 9426219 郭逸興

繳交時間超過15分鐘以上者
電子4 9326315梁彥
電子四乙 9326222 黃璽祐

未通過者下週前需補做Bonus

Quiz 10-12-2007

1. Let i, j be two integers. Write a program to exchange their values. How can you show your program is correct.

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

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月 09, 2007

10月19日,停課一次。

10月19日,老師出國發表論文,停課一次。

星期五, 10月 05, 2007

10-5-2007 Homework

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

10-5-2007 點名未到

電子三乙 郭逸興
電子三乙 李文森
電子三丙 謝志揚
電子三丙 潘冠宇
電子三甲 鄭安舜
電子四乙 黃璽祐 (有請假單)
電子四乙 林士傑 (有請假單)
電子四甲 曾韋碩
醫工四甲 東峻平

下次務必帶課本

同桌兩人可共用一本,新版或舊版不拘,下次未帶者,將開始抵扣平常分數,每次十分至零分為止。

Lab: Keyborad 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.

Lab: Adding Links on Your Blog

1. Check into your blog homepage.
2. Enter "自訂"
3. Select "連結清單"
4. Write down "http://javaatcycu.blogspot.com/" and the title as "Java物件導向程式設計"
5. Also add your own favorite links.

Programming Styles

Goal:
Make your code easy to read and easy to modify.

Spelling conventions
  • name the variables as the names suggest
  • Start the name of classes with uppercase letters (such as String, FirstProgram) and start the names of variables, objects, and methods with lowercase letters.
  • Word boundaries are indicated by an uppercase letter, as in numberOfPods
  • Java spells things out in full. Use BufferedReader instead of BufReader, BuffReader, BufferedR or BR. With abbreviations, we often cannot recall how the identifier is abbreviated.
Comments
  • "Just enough" is enough.
  • When something is important and not obvious, it merits a comment.
  • Example of unnecessary comment
interest = balance * rate; //Computes the interest.

Self-documenting
  • the structure of the program is clear from the choice of identifier names and indenting pattern.
Indenting
  • The general rule of indenting is easy. When one structure is nested inside another structure, the inside structure is indented one more level.
  • We prefer to use four spaces for each level of indenting. Indenting only two or three spaces is fine so long as you are consistent. One space is not enough to be clearly visible.

Oct-12-2007 Quiz of Chap. 1

Format: Open book, computer-based test
Running time: 30 min.
Scope: Chap. 1

星期五, 9月 28, 2007

課本

校園內敦煌書局有售,需要5天訂購時間,請及早購買。

星期四, 9月 27, 2007

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 9-28-2007 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月 21, 2007

電子系大三專題

我會在學期末舉辦小型專題說明會,並且在寒假中舉辦寒訓營,如果同學對專題有興趣的話,可以先參考我的專題部落格或是個人部落格。

Homework 9/21/2007

Due 9/28/2007 at 11:59 a.m.

"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

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月 17, 2007

9/14 課堂記事

9326125 9/14 未出席
9441142 9/14 回答問題加分

星期五, 9月 14, 2007

Lab Get familiar with JBuilder

Do Display 1.1

Homework 9/14/2007

Due 9/21/2007 at 11:59 a.m.

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.

Public Demonstration

推薦作品Kilin
Vein

如果你覺得你也寫得不錯,你可以在此留言廣為告知。

Lab: Using Firefox

Advantages of using Firefox.

Outlines of Lab

1. download Firefox 2.0

2. control font size

3. tabbed browsing

4. subscribe to the course blog

5. Using bookmarks to test RSS feed

Help



Hands on

1. Easy control of font size (try ctrl+ & ctrl- as many times as you like)
2. tabbed browsing (try ctrlT)
3. RSS feed, and support of Blog. Use the RSS feed from http://iapblog.blogspot.com/
to subscribe to it. Also subscribe to your own blog.

Note:
If your Firefox didn't work, you should check settings about proxy. It should be set as proxy.cycu.edu.tw at port 3128.

Lab 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.

星期二, 9月 11, 2007

Syllabus

3/e, international
2/e, international
3/e
2/e

1/e

上課內容, 評分原則, 課本, 上機工具

Syllabus: Object Oriented Programming in Java

Grading Policy: Participation (Presence, Challenging and Answers, Proactiveness, Quiz) 50%, Lab 30%, Homework 20%,

Instructor: Associate Professor Yao-Jen Chang

Email: yjchang at cycu dot edu dot tw (for general purpose communication)

Teaching Assistant:

Textbooks: Walter Savitch, Absolute Java , 3/e, Addison Wesley, 2008

由於上課時上機的需要, 上課務必攜帶課本,可新購或使用舊版皆可。僅限使用原版教科書

Course Outline

1.Introduction to Java

2.Java variables & assignments

3.Java control structures

4.Object oriented design concepts

5. Java abstract data type

6.Java recursion


Learning Packages:

IDE: JBuilder Foundation Edition, Free full version for free download, no registration required http://www.borland.com/products/downloads/download_jbuilder.html

Links:

History of Java

Java Tutorials by Sun

Java History: The Inside Story (Video)

James Gosling (on Wikipedia)

作業繳交方式


學生成績分布(Spring 2008),(Fall 2007)

作業批改原則

同學對本課的評語

A photo of leopard

A photo of sleeping leopard

A photo of panther

星期二, 6月 19, 2007

研究所推甄

今年底老師將招收三位推甄準研究生,有意者請隨時與我聯繫。

星期三, 6月 13, 2007

為什麼要學寫程式

電子系同學大多不重視寫程式,想不透是誰給他們寫程式不重要的錯誤概念,事實上寫程式對電子系同學的重要性絕對不亞於資工系,無論是通訊,數位,用 到程式的機會極高。現在的系統講究智慧,智慧從哪裡來? 當然是軟體。以手機為例,手機硬體大同小異,功能差異性主要來自軟體。所謂科技來自人性,軟體居功厥偉。

電子系不等於焊電路接麵包板而已,所以千萬不要輕視寫程式。寫程式的好處如下:

  • 以後工作用得上。現在的世界是買硬體送軟體,以後是買軟體送硬體。
  • 訓練清晰頭腦,培養邏輯思考能力。
  • 快速試做一個概念,因為你在耗時耗費實做之前,即可先用軟體程式模擬。如果結果不錯,再去實做不遲。

星期一, 6月 11, 2007

Lab Factorial

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

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.

星期二, 6月 05, 2007

請將 Quiz 修改後的正確答案貼在這裡

Quiz 已經全部評量完畢,未通過Quiz 的同學,請重做並且把新的正確答案貼在這裡。

星期一, 6月 04, 2007

Quiz II 結果 (未完成)

特優

從缺

未通過
電子四丙9226362黎玉全
9226315電子四丙林彥光

同學對本課評語

  • 評語(1)
    • (節錄)這學期上JAVA物件導向程式設計
      讓我可以了解JAVA的基本原理,物件導向的意義,還有method的使用
      不像之前學C++的時候 我連為什麼要寫開頭都搞不清楚
      但是再學JAVA的時候每個細節都講解的很清楚
      讓我知道我所寫的每一行程式代表的意義
      這是我學程式以來很難得的一次 ...
  • 評語(2)
    • (節錄)老師強調觀念和實作,讓大家剛吸收一些觀念就馬上去練習,藉由此方式,新學到的觀念一下就融入到腦海中。...
  • 評語(3)
  • 評語(4)
  • 評語(5)
  • 評語(6)
  • 評語(7)

Quiz 結果

特優

9427217林明駿


Quiz 未通過

電子三丙 9326329 戴志翰
電子四丙 9226362 黎玉全
電子四丙 9126338 何俊學
電子四丙 9226315 林彥光
電子三乙 9326265 梁躍叡
電子二甲 9426116 藍宇霆
應數碩二 9461006 陳志威
電子四乙 9126240 蔡明翰
電子四丙 9226330 張展魁
電子三乙 9326202 蔡勝勛
電子二乙 9426222 甘碩傑
電子二乙 9426258 李彥勳
電子二甲 9426139 劉宜鈞
電子四甲 9226151 林文翔
電子三甲 9326152 蕭名宏
電子四甲 9226148 張競升
9326138張銘仁
電子二甲 9426102 許志瑋
電子三甲 9326157 張格榮
電子二丙 9426304 徐衍翰
電子二丙 9426361 李習文
電子三甲 9326161 陳健勳
電子三甲 9326143 薛子源
電子四丙 9226332 陳鴻政(凌晨三點才上傳)

6-11 最後一次上課

因為 6-18 端午假期,6-23以後老師公假出國開會。

Quiz 6-4-2007 II

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.

Quiz 6-4-2007

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

星期一, 5月 28, 2007

Homework 5-28-2007: Sorting

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

Lab Static Method II

(1st ed.) Do Project 3 of Chap 5. Define a Complex class and write a program to compute (2+3i)+(4+5i) in Java.
(2nd ed.) Do Project 7 of Chap 5. Define a Complex class and write a program to compute (2+3i)+(4+5i) in Java.

Note:
Implement a static method and a nonstatic method using overloading. The results of these two methods should be the same.

星期三, 5月 23, 2007

星期一, 5月 21, 2007

Lab Static Method

Study Display 5.2.
Using static variables and static methods to implement the class Fibonacci such that
the first call to Fibonacci.next()
returns 2, the second returns 3, and then 5, and so on.

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);

星期五, 5月 18, 2007

6-23-2007 老師公假出國開會一周

6-23-2007 , 6-25-2007 老師公假出國開會,停課兩次。

6-18-2007 端午節停課一次。最後一次上課為 6-11-2007。

5-28-2007 第三次上機測驗

Java 基本知識,問答題 50%, 範圍課本 Chap. 1~Chap. 5, Open book
Java 物件導向程式設計,50%, 範圍課本 Chap. 1~Chap. 5, Open book

星期二, 5月 15, 2007

Homework 5-14-2007

Define a Complex class and write an object oriented program to compute (2+3i)+(4+5i) in Java.

觀察名單

如果你第一次小考未滿25分,且第二次上機考也未通過,將列入觀察名單。

5-14-2007 上機測驗通過名單

林明駿
李習文
陳志威
張嘉軒
溫建宇
鄧名鈞
(依姓氏筆畫排列)

星期一, 5月 14, 2007

上機測驗

使用 Java 寫出一個 九九乘法表。

星期一, 5月 07, 2007

5-14-2007 隨堂上機考

範圍:課本第四章
題目:隨堂公告
方式: Open Book

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();

Homework 5-7-2007: Overloading in Java

Study Display 4.11 and use Display 4.12 to call 4.11. (2nd ed.)

Study Display 4.9 and use Display 4.10 to call 4.9 (1st ed.)

星期一, 4月 30, 2007

Homework 4-30-2007

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

Lab Class Definition III

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

Requirements
1. 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?

星期日, 4月 22, 2007

星期一, 4月 16, 2007

缺課紀錄

三次缺課(學期考試扣考)
施劼岳
魏豪億

二次缺課
梁躍叡
陳健勳
薛子源

Homework 4-16-2007: Class Definitions II

Study Display 4.2 & Display 4.4 (2nd 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: Class Definition

Study Display 4.1 and then do Exercise 1.

星期一, 4月 09, 2007

Lab Exponential Funtion

Do Project 7 of Chap. 3. (2nd ed.) or Project 4 (1st ed.)

Hint: You don't have to use nested loops.

Lab Fibonacci numbers

Do Project 3.3 (1st ed.) or Project 6 (2nd ed.) Fibonacci numbers.
List the first 100 numbers and the ratio of
a number to its previous number.

Want to know more about Fibonacci number

星期二, 3月 27, 2007

3-19-2007 上課回答問題加分

9427217 資訊二 林**
9326245 電子三 馬**

成績分佈: Quiz 3-26-2007

1. 你的成績已經在你的 blog 上的回應。採筆試的同學計有五位,成績如下:
9326161 10
9226332 25
9326143 20
9226362 5
9126240 25

2. 缺考2位
9426140
9126104

3. 成績分佈(應考39位)
80~89 1
70~79 0
60~69 2
50~59 2
40~49 4
30~39 5
20~29 11
10~19 8
0~9 6

星期一, 3月 26, 2007

Homework 3-26-2007: Finding the max and the min

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: 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-26-2007

1. Revise your program for Simple Java Expression
according to Java program styles. Check the following
(1) the naming of constants, if any,
(2) Java spelling conventions, and
(3) indenting.

2. Insert proper comments in your program for Simple Java Expression. Note that there are 2 ways to insert comments: line comments and block comments.

3. The identifier BufferedReader is normally abbreviated as BR in programming language C. However, Java programmers normally do not use abbreviations in identifiers. Can you give some good reasons for using long names in Java?

4. The Java Virtual Machine handles string objects in a way different from the one it handles variables of primitive types such as int, long, float, and double. What is the difference?

星期一, 3月 19, 2007

Homework 3-19-2007

1. Do Project 1.

2. Project 3.

3. Project 8.

ps. 如果你使用第一版,請跟持有第二版的同學借閱一下。

星期二, 3月 13, 2007

Lab: Scanner

Do Display 2.6 on Page 79.

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();

Lab: Window input dialog

Use the following command to generate a window input dialog

String myString=JOptionPane.showInputDialog("Enter a number: ");

use the following command to convert a string to a number

int myNumber = Integer.parseInt(myString);

and finally use the following command to print the input number to the console

System.out.println("The number is "+ myNumber);

Don't forget the following import command

import javax.swing.JOptionPane;

so that Java can recognize JOptionPane library.

星期一, 3月 12, 2007

3/26/2007 第一次隨堂考試

範圍: 課本Chap 1. & Chap 2.

方式(Open Book):
  • 基本概念
  • 上機考

Homework 3-12-2007

1. Do Display 1.7 of Chap. 1

2. Do Project 5 of Chap. 1

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

Memo:
  1. Lab 超過下課24小時未交, 不予記分.
  2. 未交 Lab, 不僅該 Lab 不記分, 且扣平時成績.
  3. Homework 超過繳交時間(下次上課前) , 不予記分
  4. Lab 與 Homework 的重要性參看課程大綱

3-12-2007 回答問題加分

9326358
9426221

3-12-2007 點名未到

點名未到
9126104
9226147
9326114
9326161
9326265
9326305
9426140

late
9326143
9326138
9426116
9426126
9426127

務必帶課本上課

由於上課時上機的需要, 同學務必攜帶課本, 你可以向修過這門課的學長借, 無論是第一版或第二版都可以.

使用原版之教科書

由於(台灣國際圖書業交流協會書函), 叮嚀必須使用使用原版之教科書作為上課及教學之用, 所以本課程使用原版之教科書作為上課及教學, 任何課本影印本, 一律不准攜入教室.

Lab: Simple Java Expression

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

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

星期一, 3月 05, 2007

Homework 3/5/2007

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

Homework Problems due 3/12 18:50
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 First Program

Do Display 1.1 on Page 6.

星期一, 2月 26, 2007

加選成功同學(依照抽籤順序)

9326152 986
9426318 886
9226362 875
9226225 775
9126240 664
9226131 664
9326132 653
9427217 653
9326245 542
9461006 437

加選後補名單

有意加選的同學請先在下方Comment登記。

Lab Blogging

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

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

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

Blogging

Why Blog?

Things to learn with Blog

Preparing for the class

This is my sixth semester teaching Java at CYCU. These days I was looking for the reason why I kept on doing the same thing. Unless I found it, I would not be able to step into the classroom and give a good lecture, that kind of lecture students will like and remember even years after.

Watching videos about James Gosling and the persons who worked with him is very inspiring and encouraging to me. Before I found those videos on the Internet, I read some stories about how Java was created. The stories were great but the videos were even better. Both the stories and the videos fuel the passions into me, the kind of passion I need after teaching Java in 6 consecutive semesters.

Tonight, I watched Carl Sagan's TV series Cosmos followed by the Hollywood movie "Contact," which was based on Carl's novel. I felt more passions before the day ended.

星期三, 1月 24, 2007

What's next

修完 Java 之後,或許你想多練習寫一些程式。歡迎參加 Web 2.0 無線行動系統與程式設計成長冬令營 (1/30~1/31/2007)

Java 學期成績統計

祝大家寒假快樂!

(圖片點選後自動放大)

星期五, 1月 19, 2007

Web 2.0 無線行動系統與程式設計成長冬令營

時間: 2007130131

地點: 中原大學社區服務中心芳鄰成長園(位置 )

主辦: 電子系網路實驗室 (連絡電話: 4630,報名網址 http://mobilesocialtech.blogspot.com)

費用: (只接受1/26以前之網路報名)


詳細課程

星期一, 1月 08, 2007

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 Squared Array

Write a program that given an array of integers, return the squares of the array.
The sqaures are computed in a separate method rather than in the main method.