2009年2月28日 星期六

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.



15/4 = 3.75與用小算盤計算的結果相同
4/15 = 0.26666666666666666 因為使用double宣告,所以精準度到16位!
15%4 = 3.0 ==>15/4 得3餘3 正確!
4%15 = 4.0 ==>4/15 餘4 正確!

沒有留言:

張貼留言