C temperature 4th time posting this question Follow the UML

C++ temperature

4th time posting this question

Follow the UML please don\'t ignore it

Implement the temperature class depicted by the following UML representation. Your main program should look similar to this:/* * main.cpp * * Created on: Oct 5, 2016 * Author: leune */#inctude #include \"Temperature.h\" int main() {float temp = 68.0; std::cout

Solution

The code given below does only what u have mentioned in the main according to the Temperature use case.

It converts given FAHRENHEIT temp into celcius and Kelvin only

Here in getCelcius() method,the assignment will be little bit confusing but pls carefully note that Fahrenheit value is sent to the method through tem and assigned to variable celcius

class Temperature

{

float celcius;

const int CELCIUS =1;

const int FAHRENHEIT=2;

const int KELVIN =3;

public:

Temperature(float tem, int system)

{

celcius= tem;

}

float getCelcius()

{

celcius=(celcius-32)*5/9;

return(celcius);

}

float getKelvin()

{

return(celcius+273.15);

}

};

int main()

{

float temp=68.5;

cout<<\"FAHRENHEIT : \"<<temp<<endl;

Temperature t(temp,TEMPERATURE:: FAHRENHEIT);//It\'s value will be assigned to system as 2

cout<<\"In Celcius : \"<<t.getCelcius()<<endl;

cout<<\"In Kelvin : \"<<t.getKelvin()<<endl;

}

C++ temperature 4th time posting this question Follow the UML please don\'t ignore it Implement the temperature class depicted by the following UML representati
C++ temperature 4th time posting this question Follow the UML please don\'t ignore it Implement the temperature class depicted by the following UML representati

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site