2009年2月24日 星期二

Homework 2-23-2009

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

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

 
------------------------------------------------<程式碼開始>--------------------------------------
 public class HW02232009 {
    public static void main(String[] args)
    {
        double H11 = 4000.0/5280.0 ,H12 = 6000.0/5280.0, H13 = H11*5000.0, H14 = H12*5000.0;
        double H21 = 15.0/4.0, H22 = 4.0/15.0, H23 = 15.0 % 4.0, H24 = 4.0%15.0;
        System.out.println("1.\n4000 mile => $" + H13 + "\n6000 mile => $" + H14);
        System.out.println("\n2.\n15/4 = " + H21 + "\n4/15 = " + H22 + "\n15%4 = " + H23 + "\n4%15 = " + H24);
    }
}
------------------------------------------------<程式碼結束>--------------------------------------

2009年2月23日 星期一

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 減肥



------------------------------------------------<程式起始>--------------------------------------

public class inout {
public static void main(String[] args)
{
System.out.println("一罐可樂(500g)的代糖比率是0.001,");
System.out.println("一隻老鼠大約500g,");
System.out.println("根據實驗,老鼠喝體重的1/10會致癌。");
System.out.println("假設一位年輕人的體重80公斤,");
System.out.println("請問這位年輕人喝多少g可樂會致癌?");

double answer;
answer = (80 * 1000 * 0.1 /100)*500/0.5;
System.out.println("喝了 " + answer + "g");
}
}
------------------------------------------------<程式結尾>--------------------------------------

Lab: Get familiar with JBuilder

Do Display 1.1

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



------------------------------------------------<程式起始>--------------------------------------
public class inout {
public static void main(String[] args)
{
System.out.println("Hello, World! \n");
int ans1, ans2, ans3, ans4;
ans1 = 1 + 2 + 3;
ans2 = 3 - 2 - 1;
ans3 = 1 * 2 * 3;
ans4 = 2000 / 5;
System.out.println("1 + 2 + 3 = " + ans1);
System.out.println("3 - 2 - 1 = " + ans2);
System.out.println("1 * 2 * 3 = " + ans3);
System.out.println("2000 / 5 = " + ans4);
}
}
------------------------------------------------<程式結尾>--------------------------------------

Homework 1

1. 兩年前寫了幾篇文章,探討為什麼要學寫程式。參考之後,也描述一下你對寫程式的看法。
2. 參考課本第一章,回答以下問題
a. What is Java Virtual Machine and Java Bytecode?
b. Explain Java's feature "Write once, run anywhere."
Due 2/23/2009 at 18:50
1.
寫程式可以訓練自己推理、解決題目的能力,它是一項技能。
而且軟體上的應用遠大於硬體的進步,所以學習寫程式很重要。

2.
a.Java Virtual Machine意指在編譯Java程式時,
工作平台會創造出一個跑Java的環境執行,
如同虛擬機器般。
而Java Bytecode就是自己編寫的Java程式碼,
給Virtual Machine編譯。待修

b.最主要是代表說Java是跨平台的程式語言,
不需在更換平台時,還要大篇幅的修改程式碼,
所以稱"Write once, run anywhere."。

2009年2月16日 星期一

Java - Syllabus Spring 2009


上課內容, 評分原則, 課本, 上機工具
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
Emailyjchang at cycu dot edu dot tw (for general purpose communication)
Teaching Assistant:
TextbooksWalter 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 requiredhttp://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