Browse Source

Finished program

master
ludwig 2 years ago
parent
commit
663dc5bb92
  1. 40
      converter.cpp

40
converter.cpp

@ -2,21 +2,51 @@
using namespace std; 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() { int main() {
double input; int input;
char Q;
cout << "Simple temperature converter" << "\n"; cout << "Simple temperature converter \n";
cout << "Select conversion type (C F or Q for quit): "; cout << "Conversion options \n [1]C to F \n [2]F to C \n [3]Quit" << endl;
cout << "Select option [1-3]: ";
cin >> input; cin >> input;
if (input == Q) {
if (input == 3) {
cout << "Quitting..." << endl; 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); return(0);
} }
// //
// Created by fuze on 8/13/22. // Created by fuze on 8/13/22.
// //

Loading…
Cancel
Save