星期五, 10月 31, 2008

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.