2009年5月11日 星期一

Homework 5-4-2009

Do Project 7 of Chapter 4

Write a Temperature class that has two instance variables: a temperature value (a floating-point number) and a character for the scale, either C for Celsius or F for Fahrenheit. The class should have four constructor methods: one for each instance variable (assume zero degress if no value is specified and Celsius if no scale is specified), one with two parameters for the two instance variables, and a no-argument constructor (set to zero degrees Celsius).


degreesC = 5 ( degreesF - 32 ) / 9
degreesF = ( 9 ( degreesC ) / 5 ) + 32








*結果:

=>最後跑完結果似乎有點出錯,C、F轉換的數據錯誤了。不知道哪裡出了問題,還要再仔細看看。

沒有留言: