星期五, 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 減肥