#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
int main() {
double fah = 0;
double cel = 0;
string input = " ";
string yn = " ";
cout << "Welcome to the temp calculator" << endl;
cout << "-------------------------------" << endl;
do{
cout << "What would you like to convert 'Fah-Cel' or 'Cel-Fah' ";
cin >> input;
while (toupper(input) == "FAH-CEL") {
cout << "What is the Fah temp?: ";
cin >> fah;
cel = 5 * (fah - 32) / 9;
cout << fixed << setprecision(2);
cout << "The cel conversion is " << cel << " degrees" << endl;
break;
}
while (toupper(input) == "CEL-FAH") {
cout << "What is the Cel temp?: ";
cin >> cel;
fah = cel * (9 / 5) + 32;
cout << fixed << setprecision(2);
cout << "The fah conversion is " << fah << " degrees" << endl;
break;
}
if (cel >= 28 or fah >= 85) {
cout << "Boy it is gonna be hot" << endl;
}
if (cel <= 28 or fah <= 85) {
cout << "Boy it is gonna be cold" << endl;
}
cout << "Would you like to do another calculation?: ";
cin >> yn;
} while (toupper (yn) == "YES");
cout << "-----------------------------------------------" << endl;
cout << "Thank you for using the program" << endl;
return 0;
}
I am quite new to C++ so I am trying to do some basic terminal projects but I dont know why the touppers wont work here. If I remove them then the program runs fine, but if I try running it how it is VS gives me a build error. I am just trying to find a way so that the inputs arent case sensitive. Is there another way to have it to ensure users ease of use?
New contributor
Chris Valero is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.