⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 myweatherprediction.cpp

📁 C++高级编程这本书所附的源代码
💻 CPP
字号:
#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();
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -