星期五, 12月 30, 2005

星期一, 12月 26, 2005

Lab 1-02-2006 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.

Lab 12-26-2005 (2)

Write a java program and run it at command lines. Input any parameter list and output the reverse list. For example, if you enter

java someProgram 1 3 5 4 6

the putput is

6 4 5 3 1

You program should be able to handle a
null parameter, i.e. no parameters.

Lab 12-26-2005 (1)

Write a java program and run it at command lines as

java someProgram Hi ! there

The program should output

Hi there !
The length of parameter is 3.

星期一, 12月 19, 2005

Lab 1-02-2006 Recursion

Develop a recursive java code that computes factorial of N where N!= 1* 2 * 3 * ... * (N-1) * N.

Homework 12-19-2005 Lab Equal Arrays

Study Display 6.3 and define two arrays
int[] a={1,9,6,4,0,2,1,2} and int[] b={1,9,6,4,0,2,1,2}.
Write a program to verify that they are equal.

Lab 12-19-2005 Sorting

Study Display 6.1, and then write a program that can sort 5 numbers in ascending order. The 5 numbers are input by the user.

星期一, 12月 12, 2005

Homework 12-12-2005 Counter II

1. Continued from your Counter Homework, include implementations of toString method
and equals method. You should include the statements in the main that test equals method.

星期一, 12月 05, 2005

Homework 12-5-2005

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

Lab 12-12-2005 (1) Constructor

Do 4.13 and use 4.14 to call 4.13. (2nd ed.)

Do 4.11 and use 4.12 to call 4.11. (1st ed. )

Lab 12-5-2005 (2) Overloading

Step 1. Do Display 4.11 (4.9, 1st ed.) and use Display 4.12 (4.10 1st ed.) to call 4.11. (4.9 1st ed.)

Step 2.

Add two method definitions
public void setMonth(int month)
public void setMonth(String month)

Step 3.

Use Display 4.12
and change the codes in yellow shaded area as
date1.setDate(1,2,2007);
date1.setMonth(3);
date2.setDate("Feb",2,2007);
date2.setMonth("Apr");
date3.setDate(2007);

Step 4. Show the results of your program execution.

星期日, 12月 04, 2005

Lab 12-5-2005 (1) Using "this"

Based on Lab 11-28-2005,
rewrite the class program with "this" where applicable.

星期一, 11月 28, 2005

Lab 11-28-2005

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

星期一, 11月 21, 2005

Homework 11-28-2005

1. Do Project 4.5 (the Counter project) 2nd ed. or Project 4.1 1st ed. without implementing toString method
or equals method. For now, you may comment out the statements in the main that test equals method

星期一, 10月 31, 2005

Homework Lab 11-21 (2) Class Definition

Study Display 4.2 & Display 4.3 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 10-31 (1) product of N positive numbers

Compute the product of N positive numbers.
Mark the end with a negative mumber.

10-31 Quiz Fibonacci

Name 3 objects that demonstrate Fibonacci numbers and
illustrate the objects with figures.

Homework Lab 10-31 (2) Mean & Variance

Compute the variance of N positive numbers.
Mark the end with a negative mumber.

Homework 10-31 Lab (1) String Comparison

Write a Java program to check string equality for
String s1="I come from CYCU.";
String s2="I come from cycu.";

Can we do it with "=="?
What is the result for case-sensitive comparison?
What about case-insensitive?

11/14 no class

11/14 class will be rescheduled. No class on 11/14.

11/7 no class

During midterm week, we don't have class.

星期一, 10月 24, 2005

Lab 11-21 (1) Class Definition

Study Display 4.1 and then do Exercise 1.


Homework 10-24-2005 (2)

Reading Assignments:

Want to know more about Fibonacci number

Homework 10-24 (1) Lab exponential

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

星期一, 10月 17, 2005

Lab 10-31 Lab (2) Fibonacci numbers.

Do Project 3.3 Fibonacci numbers.
List the first 100 numbers and the ratio of
a number to its previous number.

Want to know more about Fibonacci number

Lab Max-Min

Based on your study of Display 3.8, write a code to find the max and min of a list of number.

Lab If-Else (2)

Based on your study of Display 3.1, develop your code for Exercise 8.

Homework 10-17

Do Project 2.05 (2nd ed.) or Project 2.03 (1st ed.)
Do Project 2.07 (2nd ed.) or Project 2.05 (1st ed.)

Reading Assignments: Sec. 1.4; Sec. 2.1, Sec. 2.2, Chap. 3 of Textbook.

Lab If-Else

Do Display 3.1.

double netIncome = some figure; // a figure you choose

Lab Scanner

Do Display 2.6 on Page 79.

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

answer

import javax.swing.JOptionPane;

public class Untitled1 {
public Untitled1() {
}


public static void main(String[] args) {

String myString=JOptionPane.showInputDialog("Enter a number: ");
int myNumber=Integer.parseInt(myString);
System.out.println("The number is "+myNumber);
System.exit(0);
}
}

Lab JOptionPane

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.

星期一, 10月 03, 2005

Lab 10-03-2005

Display 1.7 of Chap. 1

Project 5 of Chap. 1

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

星期一, 9月 26, 2005

Homework 3 09-26-2005

Reading Assignments
1. Chapter 1, Chapter 2

Homework
1. Project 1 on Page 55.

"nothing builds self-esteem and self-confidence like accomplishment"

Lab 2 09-26-2005

Do Project 4 on Page 56.

星期一, 9月 19, 2005

Homework 2

Homework Problems
1. Explain bytecode, JVM
2. Explain class, object
3. Let i=2;
Print i;
Print 2 * (i++);
Print i;

Ans: 2, 4, 3

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

Ans: 2, 6, 3

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

Ans: 3.5, 3.5

Reading Assignments
Read 1.1, 1.2, 1.3

Lab 1

Do Display 1.1

星期二, 9月 13, 2005

Homework 1

Important notices. Please read it first.

1. Try to change the settings of your blog to let it look nicer, for example,
a better look and feel by a new template, able to show Chinese and local Taipei time, anti-vandalism, and so on.
2. Why do people want to blog? Use Google to get some hints if you want.
3. Take a look at a very classic blog http://www.chieftain.idv.tw
What can you learn from this blog?

Bonus Problem:
4. What is Creative Commons? Why is it so important?

Due 9/19/2005 18:50.

Reading Assignments:
1. Chapter 1 of Absolute Java Textbook


星期一, 9月 12, 2005

課程大綱

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

Why blog?

1. Use google to search for number of users that already blog.
2. Tour total track of record at 4-year campus life. Good for all courses taken under one account.
3. Turn in exercises and homework
4. Leave essences of study materials for self recorder or open discussions
5. Teachers leave their comments and suggestions any time. Personally but openly.
6. Maintain regular discussion no matter where you are.

Things to learn about Blog

1. Use Gif verification to prevent vandelism.
2. Blog supports subscription
3. Locale & Time Zone
4. Hello for picture blogging
5. Create embedded link
6. Drafts or Publish
7. Multiple blogs under one account
8. Template selection

blogger guide

一、前言

過去一年Blog迅速成為網際網路新的一種溝通工具,不同於e-mail與IM溝通的對象是特
定的朋友、客戶或往來廠商等類型,Blog更可以溝通到素未謀面而興趣相同的讀者,本公司鼓勵員工運用這個新的溝通工具在網際網路上發言並結識同好,但也要提醒各位同
仁不要違反員工應遵守的公司規範,因此揭示下列幾個原則,以供同仁參考遵守:


二、同仁Blogging原則


1.同仁撰寫網路日誌(Blog),不刻意隱瞞文章發表者為本公司員工,同時也有義務告知
讀者,該網誌上之所有訊息不代表本公司立場。
2.撰寫與己身有關事情應以第一人稱為之。
3.不得洩漏公司機密,若不確認何者為機密應先與主管溝通。
4.不主動引起爭端,發現發表文章有錯誤宜立即修改,同時坦承疏失。
5.尊重智慧財產權並充分瞭解合理使用的範疇。
6.尊重公司、同事、顧客、合作伙伴或協力廠商,不得為惡意資訊散佈或抨擊。
7.如有連結或使用公司商標,必須事前向行政服務處取得書面同意。
8.發表與公司營運或管理有關的意見或想法,應發揮自身的判斷力並謹慎為之。
9.引用其他網路訊息,應審慎判斷其是否為惡意、偽造或杜撰不實之訊息。

三、其他相關事項

1.上述原則僅能以有限的文字敘述,運用時存乎一心,公司將定期安排相關課程以協助
有興趣撰寫Blog之同仁正確運用此工具。
2.有關員工應遵守之公司規範請參考內部資訊系統上所公布《人事規章》中的〈工作規
則〉與〈員工獎懲管理辦法〉。

張老師簡歷

張老師簡歷

星期五, 6月 17, 2005

Lab 6/17 Recursion

Study Display 11.3
Develop a recursive java code that computes factorial of N where N!= 1* 2 * 3 * ... * (N-1) * N.

Bonus problem:
Do Project 11.3 Tower of Hanoi. Try this video game.

星期五, 6月 10, 2005

Lab 6/10

Lab sorting
(if you have not finished yet.)

Lab Modularized Sorting.
(if you have already done Lab sorting.)

Lab Modularized Sorting

Rewrite the sorting program in the Lab Sorting so that
the sorting procedure is now a reusable method.

6/10 Homework (Equal Arrays)

Study Display 6.3 and define two arrays
int[] a={1,9,6,4,0,2,1,2} and int[] b={1,9,6,4,0,2,1,2}.
Write a program to verify that they are equal.

星期六, 5月 21, 2005

Lab 5/27

Lab Object Variables

Lab Sorting

Study Display 6.1, and then write a program that can sort 5 numbers in ascending order. The 5 numbers are input by the user.

Lab Object Variables

Study Display 5.9 and then write a program such that
1. an object variable aObject of class ToyClass holds the content of ("Mrs. Smith",1)
2. another object variable bObject of class ToyClass also holds the content of ("Mrs. Smith",1)
3. the other object variable cObject that have the same reference as aObject
4. Test whether aObject == bObject, meaning the two have the same reference.
5. Test whether aObject.equals(bOject), meaning the two hold the same content.
6. Test whether aObject == cObject
7. Test whether aObject.equals(cOject)

Answer to 5/20 Lab (Fibonacci Class)

public class StaticDemo
{
public static void main(String[] args)
{
for (int i = 3; i < 15; i++)
{
System.out.print("Fib( " + i + " )=" );
System.out.println(Fibonacci.next());
}
}
}


public class Fibonacci
{
private static int i=1;
private static int j=1;
private static int k;

public static int next()
{
k = i + j;
j = k;
i = j;
return k;
}
}

星期五, 5月 20, 2005

5/20 Lab (Fibonacci Class)

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

星期日, 4月 17, 2005

5/13 Lab

1. For Display 4.9,

1.1
in overloaded setDate()
replace monthInt with month,
replace monthString with month,

and then make necessary code changes so that the program still runs correctly.


1.2
in overloaded dateOK()
replace monthInt with month,
replace monthString with month,

replace dayInt with day,
replace yearInt with year,

and then make necessary code changes so that the program still runs correctly.

1.3
in readLinput()
replace dayInput with day,
replace monthInput with month,
replace yearInput with year,

and then make necessary code changes so that the program still runs correctly.

1.4
in setMonth()
replace monthNumber with month,

and then make necessary code changes so that the program still runs correctly.

1.5
in monthString(),
replace monthNumber with month,

and then make necessary code changes so that the program still runs correctly.


5/13 Homework

1. Continued from your 5/6 Homework, do Project 4.1 (the Counter project) including implementations of toString method
and equals method. You should include the statements in the main that test equals method.

2. Do Project 4.3 (the Temperature project)

3. Do Project 4.4

4/29 Homework

Do Project 3.4 (the Taylor project)

5/6 Homework (Counter Class)

1. Do Project 4.1 (the Counter project) without implementing toString method
or equals method. For now, you may comment out the statements in the main that test equals method.

5/6 Lab

Study Display 4.1 and then do Exercise 1.

Study Display 4.2 & Display 4.3 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月 16, 2005

4/29 Lab

Based on your study of Display 3.8, write a code to find the max and min of a list of number.

Do Project 3.3 Fibonacci numbers.
List the first 100 numbers and the ratio of
a number to its previous number.

Want to know more about Fibonacci number

4/15 Lab

1. Do Display 3.1 on JBuilder and test the results.
2. Based on your study of Display 3.1, develop your code for Exercise 8.

4/22 no class

no class 4/22 because we don't have midterms.

星期五, 4月 01, 2005

4/1 Homework

1. Do Project 2.03
2. Do Project 2.05

4/1 Lab

Try Display 2.04 and then do Project 2.01

星期五, 3月 25, 2005

3/25 Homework

Reading Assignments:

1. Redo Display 2.03 using d=123.456789 & money=0.001. Watch the results.
2. Do Display 2.01 using 5 different Locale. (For example, Taiwan, China, France.)
3. Hit the Internet and do a search. Based on the results you find, write a Cellular Phone Java Game market report on your own blog.
4. Reading Assignments: Sec. 1.4; Sec. 2.1, Sec. 2.2 of Textbook.

3/25 Lab

Programming Project 1.02 using JBuilder

星期五, 3月 18, 2005

3/18 Homework

Do 3/18 Lab


Reading Assignments:
1. Read Sec. 1.3, Sec. 1.4; Sec. 2.1, Sec. 2.2 of Textbook.

3/18 Lab

Practice JBuilder

Do 1.02, 1.7, 1.8

星期五, 3月 11, 2005

3/11 Homework

Do 3/11 Lab

Reading Assignments:
1. Review Sec 1.1, Sec 1.2 of textbook.
2. Read Sec. 1.3, Sec. 1.4; Sec. 2.1, Sec. 2.2 of Textbook.

Due next Friday 18:30

3/11 Lab

3/11 Lab

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

Ans: 2, 4, 3

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

Ans: 2, 6, 3

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

Ans: 3.5, 3.5

4. Codemate 1.01

Ans: Consumption of 1136.3636363636365 kg of soda would kill a person weighing 50.0 kg.


5 Codemate 1.03

星期五, 3月 04, 2005

Homework 2

CodeMate Programming Projects:

  • 1.01 - page 54
  • 1.02 - page 55
  • 1.03 - additional project
  • 1.04 - additional project
Reading Assignments:
Read Chapter 1 of textbook.

Due next Friday 18:30

課程大綱

Syllabus: Object Oriented Programming in Java

Time: 18:55 p.m. - 21:30 p.m. Monday

Place:

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

Instructor: Associate Professor Yao-Jen Chang

Email: yjchang@cycu.edu.tw (for general purpose communication)

Teaching Assistant:

Textbooks:

Walter Savitch, Absolute Java ,2/e, Addison Wesley, 04/08/2005

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)

作業繳交方式



星期六, 2月 26, 2005

Homework 1

1. Read Chapter 1 of textbook.
2. Practice on your Codemate and get familiarized with it.

Due next Monday at 18:30

Please write your homework at your own blog. Then post your blog URL here using
Post a comment so that your submission can be timemarked and your classmates can take a look of your work.