#include <iostream>
#include <iomanip>
using namespace std;
void far_cels();
void cels_far();
void quit();
void answerF(double);
void answerC(double);
double getTemp();
int main()
{
cout << "--MENU--\n" << "PLease make a selection\n"
<< "1: Farenheit to Celsius conversion\n"
<< "2: Celsius to Farenheit conversion\n"
<< "3: Quit Program\n"
<< "MAKE SELECTION : ";
int num = 0;
cin >> num;
switch (num) {
case 1:far_cels();
case 2:cels_far();
case 3: quit();
default: return main();
}
}
double getTemp()
{
double temp;
cout << "Enter the tempature you want to convert\n";
cin >> temp;
return temp;
}
void far_cels()
{
double farenheit;
double celsius;
farenheit = getTemp();
celsius = farenheit - 32 / 1.8;
answerC(celsius);
}
void cels_far()
{
double farenheit;
double celsius;
celsius = getTemp();
farenheit = celsius * 1.8 + 32;
answerF(farenheit);
}
void answerF(double farenheit)
{
cout << "The Tempature is: " << endl;
cout << setprecision (4);
cout << farenheit <<" degrees farenheit " << endl;
}
void answerC(double celsius)
{
cout << "Your temperature is: " << endl;
cout << setprecision (4);
cout << celsius <<" degrees celsius " << endl;
}
void quit(){
}
I can not seem to figure out how to clear the screen and return main() if the switch statement is not activated. I have figured out how to return to main but the menu is still there. Any help would be greatly appreciated I am just starting out and need all the advice I can get. The other parts of the code seem to work well but if I anyone can see problems in what I am doing that would also be greatly appreciated. I am also using Xcode on a mac.