> unit; if (unit == 'F' || unit == 'f'){ cout << "Enter the temperature in Celsius: "; cin >> temp; temp = (1.8 * temp) + 32.0; cout << "Temperature is: " << temp << "F\n"; }else if(unit == 'C' || unit == 'c'){ cout << "Enter the temperature in Fahrenheit: "; cin >> temp; temp = (temp - 32) / 1.8; cout << "Temperature is: " << temp << "C\n"; }else{ cout << "Please enter in only C or F\n"; } cout << "***************************"; }"> > unit; if (unit == 'F' || unit == 'f'){ cout << "Enter the temperature in Celsius: "; cin >> temp; temp = (1.8 * temp) + 32.0; cout << "Temperature is: " << temp << "F\n"; }else if(unit == 'C' || unit == 'c'){ cout << "Enter the temperature in Fahrenheit: "; cin >> temp; temp = (temp - 32) / 1.8; cout << "Temperature is: " << temp << "C\n"; }else{ cout << "Please enter in only C or F\n"; } cout << "***************************"; }"> > unit; if (unit == 'F' || unit == 'f'){ cout << "Enter the temperature in Celsius: "; cin >> temp; temp = (1.8 * temp) + 32.0; cout << "Temperature is: " << temp << "F\n"; }else if(unit == 'C' || unit == 'c'){ cout << "Enter the temperature in Fahrenheit: "; cin >> temp; temp = (temp - 32) / 1.8; cout << "Temperature is: " << temp << "C\n"; }else{ cout << "Please enter in only C or F\n"; } cout << "***************************"; }">
#include <iostream>
using namespace std;
int main() {
double temp;
char unit;
cout << "***** Temperature Conversion *****\\n";
cout << "F = Fahrenhait\\n";
cout << "C = Celcius\\n";
cout << "What unit would you like to convert to: ";
cin >> unit;
if (unit == 'F' || unit == 'f'){
cout << "Enter the temperature in Celsius: ";
cin >> temp;
temp = (1.8 * temp) + 32.0;
cout << "Temperature is: " << temp << "F\\n";
}else if(unit == 'C' || unit == 'c'){
cout << "Enter the temperature in Fahrenheit: ";
cin >> temp;
temp = (temp - 32) / 1.8;
cout << "Temperature is: " << temp << "C\\n";
}else{
cout << "Please enter in only C or F\\n";
}
cout << "***************************";
}
This is a simple C++ program that converts temperature between Fahrenheit and Celsius. It prompts the user to enter the temperature and the unit they would like to convert to. If the user enters 'F' or 'f', the program converts Celsius to Fahrenheit. If the user enters 'C' or 'c', the program converts Fahrenheit to Celsius. If the user enters any other character, the program displays an error message. The program then outputs the converted temperature in the desired unit.