Created
November 24, 2016 02:33
-
-
Save met4000/59f6912426be6c0ac542c1d81d06b17e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <iostream> | |
using namespace std; | |
int main() | |
{ | |
string from, to, disp, v; | |
int value; | |
bool a = true; | |
do { | |
cout << "What would you like to convert from?" << endl << ">>"; | |
cin >> from; | |
} while (from != "C" && from != "F" && from != "K"); | |
cout << "What would you like to convert to?" << endl << ">>"; | |
cin >> to; | |
cout << "Calculator:" << endl << ">>"; | |
disp = to == "C" ? "Celsius" : to == "F" ? "Fahrenheit" : to == "K" ? "Kelvin" : "N/A"; | |
while (a) { | |
cin >> v; | |
if (from == "F") { | |
value = (value - 32) / 1.8; | |
} | |
else if (from == "K") { | |
value -= 273; | |
} | |
if (to == "F") { | |
value = value * 1.8 + 32; | |
} | |
else if (to == "K") { | |
value += 273; | |
} | |
cout << value << " degrees " << disp << endl << ">>"; | |
} | |
a = true; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment