Solution_TakeHome1_S09

# Solution_TakeHome1_S09 - Take home practice for midterm 1...

This preview shows pages 1–2. Sign up to view the full content.

Take home practice for midterm 1 Spring 2009 You are to design a class that would represent a given temperature in Fahrenheit to different units. Given the following UML representation of a class write the C++ code for the class: class Temp_Convertor{ private : Celsius, Fahrenheit, Kelvin ; public : void Set_Fah (double fah ){ Fahrenheit = fah ; Celsius = To_Celsius() ; Kelvin = To_Kelvin(); } void print (){ cout << Fahrenheit << “\t” << Celsius <<”\t” << Kelvin ; } double To_Kelvin(){ return ( Celsius + 273 ) ; } double To_Celsius () { return (5.0 / 9 * ( Fahrenheit – 32)); } Temp_Convertor () { Fahrenheight = 0 ; Celsius = To_Celsius() ; Kelvin = To_Kelvin(); } Temp_Convertor ( double fah) { Fahrenheight = fah ; Celsius = To_Celsius() ; Kelvin = To_Kelvin(); } } Temp_Convertor - Celsius : double - Fahrenheit : double - Kelvin : double + Set_Fah(double ): void // Sets Fahrenheit to the given value + Print():void // prints the temperatures in Fahrenheit, Celsius and Kelvin separated by a tab

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### Page1 / 2

Solution_TakeHome1_S09 - Take home practice for midterm 1...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online