Hello, I got a new problem. Our teacher asked us to create a menu-driven program which will make all types of conversions (http://classroom.sdmesa.edu/vtrinh/pp4.html). This program must be able to do conversions back and forth (like inches to centimeters, and centimeters to inches). Below I started the assignment and so far I have managed to get the main menu to display, and the choice, but I want to link it so that it goes on to display the menu that the person entered (right now ther is only 1 menu available that being 1). I do have a general idea of what I need to do, but can someone help me? I believe he made mention of some reciprocal factor, which allows 1 function to act as 2, he said something like convert ("inches", "centimeters", (1.0/InToCm)), he also made mention of 3 things, string to, string from, and a factor.

``````#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int choose =1;
while ( choose != 5 )
{
do
{
if ( choose > 5 || choose <= 0 ) //If not in the range 1-5
{
cout << "\nChoose A Conversion Type: \n ";
//cout << "\nPress <Enter> key to continue ... ";
fflush(stdin);
cin.get();  //Refreshes page.
}

choose = mainmenu(); // Function call to get the user's choice

} while ( choose <=0 || choose > 5 );

if ( choose != 5 )
switch (choose)
{
case 1:
cout << "You have picked distance conversion"<< endl;
break;
cin.get();
case 2:
cout << "You have picked weight conversion";
break;
case 3:
cout << "You have picked volume conversion";
break;
case 4:
cout << "You have picked pressure conversion";
break;
}// branch to an appropriate selection

cin.ignore();
cin.get();
return 0;
}
}
{
system ("cls");
int choose;
cout << "    M A I N M E N U " << 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| E N D - P R O G R A M"<< endl;
cout << "Please Choose A Conversion Type To Continue..."<< endl;
while (! (cin >> choose))
{
cin.clear();
fflush(stdin);
}
return choose;
}
{
system ("cls");
int distancechoosefunction;
cout << "    D I S T A N C E M E N U";
cout << "    _______________________";
cout << "    1| Inches To Centimeters";
cout << "    2| Centimeters To Inches";
return distancehoosefunction;
}

double InchesToCentimeters(string to, string from (1.0/InchesToCentimeters))
{

}``````

## All 2 Replies

There are five options so I would do something like:-

``````... If choose == 1
then
If choose == 2
then
If choose == 3
then
If choose == 4
then
else``````

More importantly, if you are new to programming, go draw yourself a flow chart before you start coding.

Use switch statement to solve this match the case and call particular function according to that

Best Of Luck

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, learning, and sharing knowledge.