homework problem

i need to create c++class to store temperature. class should store temperature(magnitude) and scale (celsius, fahrenheit)class should have constructors as well as member functions to return the temperature in either scale.
i got this so far but not sure if its right and its not finished

#include <iostream>
#include <cstdlib>
using namespace std;
class Temperature{
public:
enum TemperatureScale{
celsius,
fahrenheit
};
private:
double value;
TemperatureScale scale;


public:
Temperature (double_value, TemperatureScale_scale): value(_value), scale(_scale){
};
double getCelsius(){
if (scale == fahrenheit) return (value - 32)/1.8;
return value;
}
double getFahrenheit(){
if (scale == celsius) return (1.8 * value) + 32;
return value;
}
Try to use the code tags(lower right of post, "<>")
Im pretty use you're missing some code? you declare public twice in the code, a class should look like this:

1
2
3
4
5
6
7
8
9
Class classEX
{
      public:
          //.....
      protected:
          //....
      private:
         //...
};
Topic archived. No new replies allowed.