📄 myweatherprediction.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 + -