1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84
|
// Wind Chill Factor.cpp
/*Write a program that inputs the current temperature, the temperature scale (c for Celsius or f for Fahrenheit), and the wind speed in miles per hour
, then calculates and outputs the wind chill factor using the same temperature scale as that which was entered as input.
Temperature and wind speed may include decimal places. Temperature output should use one decimal place.
You may assume that input will be valid and the scale will be entered in lowercase.
*/
//created by: J L
#include "pch.h"
#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;
int main()
{
double Fahrenheit, F, Celsius, C, Windchill, V, windspeed;
cout << "Hello there...\n\nThis program is a windchill factor calculator.\n";
while (1)
{
char option[2];
cout << "\nEnter the number of one of the following:\n"
<<"MENU:\n\n"
<< "1.Wind Chill Factor for Fahrenheit.\n"
<< "2.Wind Chill Factor for Celsius.\n"
<< "3. Exit Program.\n"
<< "Choice:";
cin >> option;
if (option[0] == '1')
{
system("CLS");
cout << "Enter a value for Celsius to be converted to Fahrenheit: ";
cin >> Celsius;
cout << "\nEnter a value for wind speed: ";
cin >> windspeed;
C = Celsius;
V = windspeed;
F = (5 / 9) * C + 32;
Windchill = 35.74 + 0.6215 * F - 35.15 * pow(F, 0.16) +0.4275 * F * pow(V,0.16);
cout << "The temperature in Fahrenheit is " << F << " degree.\n"
<< "The windspeed is: " << V << " miles per hour.\n"
<< "The Wind Chill is: " << Windchill << endl;
system("PAUSE");
system("CLS");
}
else if (option[0] == '2')
{
system("CLS");
cout << "Enter a value for Fahrenheit to be converted to Celsius: \n";
cin >> Fahrenheit;
cout << "\nEnter a value for wind speed: \n\n";
cin >> windspeed;
F = Fahrenheit;
V = windspeed;
C = 9/5 * (F - 32);
Windchill = 35.74 + 0.6215 * C - 35.15 * pow(C, 0.16) + 0.4275 * C * pow(V, 0.16);
cout << "The temperature in Celsius is " << C << "degree.\n"
<< "The Wind Speed are: " << V << "mph.\n"
<< "The Wind Chill is: " << Windchill << endl;
system("PAUSE");
system("CLS");
}
else if (option[0] == '3')
{
return 0;
}
else if (option[0] > '3' || option[0] < '1')
{
system("CLS");
cout << "Invalid Entry";
system("PAUSE");
system("CLS");
}
else
{
system("CLS");
cout << "Invalid Entry";
system("PAUSE");
system("CLS");
}
}
}
| |