topical media & game development

talk show tell print

professional-program-10-WeatherPrediction-MyWeatherPrediction.c

? / professional-program-10-WeatherPrediction-MyWeatherPrediction.c


  include <iostream>
  
  include <MyWeatherPrediction.h>
  
  using namespace std;
  
  void MyWeatherPrediction::setCurrentTempCelsius(int inTemp)
  {
    int fahrenheitTemp = convertCelsiusToFahrenheit(inTemp);
    setCurrentTempFahrenheit(fahrenheitTemp);
  }
  
  int MyWeatherPrediction::getTomorrowTempCelsius()
  {
    int fahrenheitTemp = getTomorrowTempFahrenheit();
    return convertFahrenheitToCelsius(fahrenheitTemp);
  }
  
  void MyWeatherPrediction::showResult()
  {
    cout << "Tomorrow's temperature will be " << 
      getTomorrowTempCelsius() << " degrees Celsius (" <<
      getTomorrowTempFahrenheit() << " degrees Fahrenheit)" << endl;
  
    cout << "The chance of rain is " << (getChanceOfRain() * 100) << " percent"
         << endl;
  
    if (getChanceOfRain() > 0.5) {
      cout << "Bring an umbrella!" << endl;
    }
  }
  
  int MyWeatherPrediction::convertCelsiusToFahrenheit(int inCelsius)
  {
    return (int)((9.0/5.0) * (inCelsius + 32));
  }
  
  int MyWeatherPrediction::convertFahrenheitToCelsius(int inFahrenheit)
  {
    return (int)((5.0/9.0) * (inFahrenheit-32));
  }
  
  int main()
  {
    MyWeatherPrediction p;
    p.setCurrentTempCelsius(33);
    p.setPositionOfJupiter(80);
    p.showResult();
  }
  


(C) Æliens 20/2/2008

You may not copy or print any of this material without explicit permission of the author or the publisher. In case of other copyright issues, contact the author.