星期五, 11月 21, 2008

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

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月 19, 2008

大三專題指導

有興趣找我做專題同學,請參閱大學部專題特區。我們會先在1/16/2009 舉辦行動科技輔具冬令營隊,介紹專題內容與基礎能力。有興趣者,請自行組成專題團隊。

本次招收10位同學,若干團隊(每隊2人),冬令營活動結束後,將進行個別團隊洽談。

星期一, 11月 17, 2008

星期五, 10月 31, 2008

Homework 10-31-2008

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

Answer to Quiz

1. Write a Java program to calculate the trianular function as follows:
Cos(x)=1 - 2!/x 2 + 4!/x 4- 6!/x 6...

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


6. Write a complete Java program that uses a for loop to compute the sum of odd numbers between 1 and 25.

int evenSum=oddSum=0;

for(i=1; i<=25; i++)
{
if(i%2!=0)

oddSum+=i;

}

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?