Recently I was assigned to create a program driven by a main menu, followed by a submenu, followed by functions. Below is an attempt of mine, which does display the main menu, and from there a user must enter a value to proceed to a second menu, however it doesn't seem to work, is there anybody that can help? NOTE: The program is far from complete, so the only choice available is "1", which will select the distance conversion, but my problem is that it won't display on the screen, when it does, it should have more options.
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int MainMenu();
int menu0(int);
double DistanceConversion(string, string, double);
int main()
{
int choosefunction = 1;
while ( choosefunction != 5 )
{
do
{
if (choosefunction > 5 || choosefunction <= 0)
{
cout << "Are you on drugs? Try Again: " ;
cin.clear();
fflush(stdin);
}
} while (choosefunction < 0 || choosefunction > 5);
choosefunction = MainMenu();
}
if (choosefunction != 5)
switch (choosefunction)
{
case 1:
int DistanceConversion();
}
fflush(stdin);
cin.get();
return 0;
}
int MainMenu()
{
system ("cls");
int choosefunction;
cout << " M A I N M E N U"<< endl;
cout <<" PLEASE PICK AN OPTION"<<endl;
cout << " ________________________" << endl;
cout << " 1 | Distance Conversion" << endl;
cout << " 2 | Weight Conversion" << endl;
cout << " 3 | Volume Conversion" << endl;
cout << " 4 | Pressure Conversion" << endl;
cout << " 5 | END PROGRAM" << endl;
while (!(cin >> choosefunction))
{
cout << "Don't lie, you are using drugs. Thats not even on the Menu." << endl
<< "Re-Enter a choice thats on the Menu: ";
cin.clear();
fflush(stdin);
}
return choosefunction;
}
double DistanceConversion(string to, string from, double factor)
{
}
int menu0(int choosefunction)
{
int choosefuntion;
system("cls");
cout << " D I S T A N C E C O N V E R S I O N";
while (!(cin >> choosefunction))
{
cout << "\n Invalid Please Re-Enter: ";
cin.clear();
fflush(stdin);
}
return choosefunction;
}