I am new to C++ and I am having problems with my code as you may imagine. As a newbie, I am creating an application in which converts celsius to fahrenheit and vice versa. The application has to ask what the user wants. I set up the application to run but the problem is that I don't know what else to do to go from a function to a switch. I am stuck on main, where I declare getMenuSelection and try to move onto the switch.I only went as far as putting the case: F just as a testing method. If any programming masters can help, I would appreciate it, thanks. Below is my code;
#include <iostream>
#include <cmath>
#include <iomanip>
#include <stdio.h>
using namespace std;
void displayMenu(void)
{// Function displayMenu()
cout << "Please enter one of the following choices to begin:" << endl;
cout << "\n\t F or f => Convert from Celcius to Fahrenheit.";
cout << "\n\t C or c => Convert from Fahrenheit to Celcius.";
cout << "\n\t Q or q => Quit" << endl;
}
char getMenuSelection(char fahcel)
{
char fahCel;
cout << "Your entered:";
cin >> fahCel;
return 0;
}
double getStartEndAndIncrement(double statemp, double endtemp, double incr)
{
double staTemp,
endTemp,
inc;
cout << "Enter starting temperature, ending temperature, and increment value: " << "\n" << endl;
cin >> staTemp >> endTemp >> inc;
return 0;
}
double cToF(double staTemp, double endTemp)
{
double statemp,
endtemp,
celsius = 0,
fahrenheit = 0;
statemp = celsius,
endtemp = celsius;
fahrenheit = celsius * 9.0/5.0 + 32; // Formula Cel to Fah
return 0;
}
double fToC(double staTemp, double endTemp)
{
double statemp,
endtemp,
celsius = 0,
fahrenheit = 0;
statemp = fahrenheit,
endtemp = fahrenheit;
celsius = fahrenheit * 9.0/5.0 - 32; // Formulas Fah to Cel
return 0;
}
double displayCToFTable(double staTemp, double endTemp, double inc)
{
double statemp,
endtemp,
incr = 0,
result;
statemp = 0,
endtemp = 0;
while (-1000 >= statemp && endtemp <= 1000);
{//Start while loop
printf("%6.2f degrees C = %6.2f degrees F\n",
statemp, (statemp + 32.0) * 5.0 / 9.0);
if (statemp > endtemp)
cout << "Starting temperature higher than ending temperature!!" << endl;
else
result = statemp + incr;
}//End while loop
return 0;
}
double displayFToCTable(double staTemp, double endTemp, double inc)
{
double statemp,
endtemp,
incr = 0,
result;
statemp = 0,
endtemp = 0;
while (-1000 >= statemp && endtemp <= 1000);
{//Start while loop
printf("%6.2f degrees F = %6.2f degrees C\n",
statemp, (statemp - 32.0) * 5.0 / 9.0);
if (statemp > endtemp)
cout << "Starting temperature higher than ending temperature!!" << endl;
else
result = statemp + incr;
}//End while loop
return 0;
}
char fahCel;
int main()
{
double fahrenheit = 0,
celsius = 0;
char choice;
cout << "This is a conversion program that converts Celsius to Fahrenheit and vice versa. " << endl;
displayMenu();
choice = getMenuSelection(fahCel);
switch (choice)
{// Start Switch
case 'f':
case 'F':
cout << "Converting from Celsius to Fahrenheit. " << endl << "\n" << endl;
double getStartEndAndIncrement(double statemp, double endtemp, double incr);
double cToF(double staTemp, double endTemp);
double displayCToFTable(double staTemp, double endTemp, double inc);
}// Ending brace for Switch
cin.ignore(2);
return 0;
}// Ending brace for Main