Solution_TakeHome1_S09

Solution_TakeHome1_S09 - Take home practice for midterm 1...

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

View Full Document Right Arrow Icon
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
Background image of page 1

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

View Full Document Right Arrow Icon
Image of page 2
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 Right Arrow Icon
Ask a homework question - tutors are online