diff --git a/converter.cpp b/converter.cpp index 55a1b55..8e67103 100644 --- a/converter.cpp +++ b/converter.cpp @@ -2,21 +2,51 @@ using namespace std; +double C, F; + +double convertC(double C, double F){ + C = (F - 32) / 1.8; + return(C); +} + +double convertF(double C, double F){ + F = (C * 1.8) + 32; + return(F); +} + int main() { - double input; - char Q; - cout << "Simple temperature converter" << "\n"; - cout << "Select conversion type (C F or Q for quit): "; + int input; + + cout << "Simple temperature converter \n"; + cout << "Conversion options \n [1]C to F \n [2]F to C \n [3]Quit" << endl; + cout << "Select option [1-3]: "; cin >> input; - if (input == Q) { + + if (input == 3) { cout << "Quitting..." << endl; } + + else if (input == 1){ + cout << "Enter temperature in Celsius: "; + cin >> input; + C = input; + cout << convertF( C, F) << endl; + } + + else if (input == 2){ + cout << "Enter temperature in Fahrenheit: "; // <- should this be C to F? + cin >> input; + F = input; + cout << convertC(C, F); + } + return(0); } + // // Created by fuze on 8/13/22. //