Hello all, I am a major noob a C++ and need some help with managing case. we are to write program that asks the user to enter a temperature and a single letter, F for Farenheit or C for Celsius. The program should manage the upper or lower case input symbols, F or f for Fahrenheit or C or c for Celsius. Then, terminate the program for all of the other input symbols. If the letter is F, the program converts the input temperature in F to the temperature in Celsius. If the letter is C, the program converts the input temperature in C to the temperature in Farenheit. The program displays input temperature, input letter symbol, converted temperature and the converted temperature unit symbol. I have most of the program complete but cannot figure out how to get it to recognize the letters F or C....Here is my code
//Advanced Temperature Conversion Program
#include<iostream>
#include<iomanip>
#include<cmath>
using namespace std;
//Section 1: define variables
double temp;
int sym;
double conv;
int main()
{
cout <<fixed<<setprecision(2)<<showpoint; //show decimal to 2 places
//Section 2: User input
cout <<"This is a simple program that will convert a temperature to either"<<endl;
cout <<"celsius or farenheight."<<endl;
cout <<endl;
cout <<"Please enter a temperature. ";
cout <<endl;
cin >>temp;
cout <<endl;
cout <<"What would you like to convert to?";
cout <<endl;
cout <<"Enter F for Farenheight or C for Celsius. ";
cin >>sym;
cout <<endl;
switch (sym)
{
case 'F':
case 'f':
case 'C':
case 'c':
if (sym == 'F' )
{
cout <<setw(10)<<"Input Temp"<<setw(14)<<"Input Symbol"<<setw(17)<<"Converted Temp"<<setw(18)<<"Converted Symbol";
cout <<endl;
cout <<setw(10)<<"__________"<<setw(14)<<"____________"<<setw(17)<<"______________"<<setw(18)<<"________________";
cout <<endl;
cout <<temp<<setw(12)<<"F"<<setw(17)<<(temp-32)*5/9<<setw(18)<<"C";
cout <<endl;
}
else if (sym == 'C')
{
cout <<setw(10)<<"Input Temp"<<setw(14)<<"Input Symbol"<<setw(17)<<"Converted Temp"<<setw(18)<<"Converted Symbol";
cout <<endl;
cout <<setw(10)<<"__________"<<setw(14)<<"____________"<<setw(17)<<"______________"<<setw(18)<<"________________";
cout <<endl;
cout <<temp<<setw(12)<<"C"<<setw(17)<<9/5 * (temp+32)<<setw(18)<<"F";
cout <<endl;
cout <<endl;
}
}
system ("pause");
return 0;
}