Browse Source

Comments

master
ludwig 2 years ago
parent
commit
7ab4b91cfa
  1. 8
      converter.cpp

8
converter.cpp

@ -5,7 +5,7 @@ using namespace std;
void Menu(){
void Menu(){ // <- The menu is (mostly) static, no need for it to be in main
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]: ";
@ -13,12 +13,12 @@ void Menu(){
double C, F;
double convertC(double C, double F){
double convertC(double C, double F){ // <- converts to Celsius
C = (F - 32) / 1.8;
return(C);
}
double convertF(double C, double F){
double convertF(double C, double F){ // <- converts to fahrenheit
F = (C * 1.8) + 32;
return(F);
}
@ -40,7 +40,7 @@ int main() {
}
else if (input == 2){
cout << "Enter temperature in Fahrenheit: "; // <- should this be C to F?
cout << "Enter temperature in Fahrenheit: ";
cin >> input;
F = input;
cout << convertC(C, F);

Loading…
Cancel
Save