i want to create a code using multiple menus but im having a hard time
when i input the value for my first menu it also show the question for the second menu..
can you help me out..??
#include <iostream>
#include <iomanip>
#include <windows.h>
using namespace std;
int main()
{
char choice;
float ft,acre,lb,oz,gal,ton,in,mi;
float m,ha,kg,g,lit,mt,mm,km;
int select = 0;
int choose = 0;
do
{
cout<< endl<< endl<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl<< endl
<<setw(70) << "~ The Metric and English Convertion ~" << endl<< endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << " " << endl
<<setw(70) << "::::::::::::::::::::::INSTRUCTIONS:::::::::::::::::::::::::" << endl
<<setw(70) << " " << endl
<<setw(70) << " Please Enter the Number of The Menu " << endl
<<setw(70) << " " << endl
<<setw(70) << ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl<< endl
<<setw(70) << "~~ a) English to Metric ~~" << endl
<<setw(70) << "~~ B)/> Metric to English ~~" << endl<< endl
<<setw(70) << ":::::::::::::::::::::::::::::::::::::::::::::::::::::::::::" << endl<< endl
<<setw(55) << "Please enter your choice [1 or 2]: ";
cin >> select;
system("cls");
if (select == 1)
{
cout<< endl<< endl<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl<< endl
<<setw(70) << "~ The English to Metric Convertion ~" << endl<< endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout <<setw(57)<< "Please select from the following: " << endl<< endl;
cout <<setw(39)<< "1) Feet to Meter" << endl;
cout <<setw(42)<< "2) Acre to Hectares" << endl;
cout <<setw(44)<< "3) Pound to Kilograms" << endl;
cout <<setw(41)<< "4) Ounces to Grams" << endl;
cout <<setw(43)<< "5) Gallons to Liters" << endl;
cout <<setw(45)<< "6) Tons to Metric Tons" << endl;
cout <<setw(47)<< "7) Inches to Millimeters" << endl;
cout <<setw(45)<< "8) Miles to Kilometers" << endl<<endl;
cout <<setw(30)<< "Enter: ";
cin >> choose;
system("cls");
}
if (choose == 1)
{
cout<< endl<< endl<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl<< endl
<<setw(70) << "~ Feet to Meters ~" << endl<< endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout <<" Enter how many Feet: ";
cin >> ft;
m = ft*0.3048;
cout << "Equivalent in Meters is: " << m << endl;
}
else if (choose == 2)
{
cout<< endl<< endl<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl<< endl
<<setw(70) << "~ Feet to Meters ~" << endl<< endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl
<<setw(70) << "~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~" << endl;
cout <<" Enter how many Acres: ";
cin >> acre;
ha = acre*0.4046873;
cout << "Equivalent in Hectares is: " << ha << endl;
}
else if (choose == 3)
{
cout <<" Enter how many Pounds: ";
cin >> lb;
kg = lb*0.453592;
cout << "Equivalent in Kilograms is: " << kg << endl;
}
else if (choose == 4)
{
cout <<" Enter how many Ounces: ";
cin >> oz;
g = oz*28.34952;
cout << "Equivalent in Grams is: " << g << endl;
}
else if (choose == 5)
{
cout <<" Enter how many Gallons: ";
cin >> gal;
lit = gal*3.785412;
cout << "Equivalent in Liters is: " << lit << endl;
}
else if (choose == 6)
{
cout <<" Enter how many Tons: ";
cin >> ton;
mt = ton*0.9071847;
cout << "Equivalent in Metric Tons is: " << mt << endl;
}
else if (choose == 7)
{
cout <<" Enter how many Inches: ";
cin >> in;
mm = in*25.4;
cout << "Equivalent in Millimeters is: " << mm << endl;
}
else if (choose == 8)
{
cout <<" Enter how many Miles: ";
cin >> mi;
km = mi*1.609347;
cout << "Equivalent in Kilometers is: " << km << endl;
}
else if(select == 2)
{
cout << "Please select from the following: " << endl;
cout << "1) Meter to Feet" << endl;
cout << "2) Hectares to Acres" << endl;
cout << "3) Kilograms to Pounds" << endl;
cout << "4) Grams to Ounces" << endl;
cout << "5) Liters to Gallons" << endl;
cout << "6) Metric Tons to Tons" << endl;
cout << "7) Millimeters to Inches" << endl;
cout << "8) Kilometers to Miles" << endl<<endl;
cout << "Enter: ";
cin >> choose;
system("cls");
}
if (choose == 1)
{
cout <<" Enter how many Meters: ";
cin >> m;
ft = m*3.28084;
cout << "Equivalent in Feet is: " << ft << endl;
}
else if (choose == 2)
{
cout <<" Enter how many Hectares: ";
cin >> ha;
acre = ha*0.4046873;
cout << "Equivalent in Acres is: " << acre << endl;
}
else if (choose == 3)
{
cout <<" Enter how many Kilograms: ";
cin >> kg;
lb = kg*2.204623;
cout << "Equivalent in Pounds is: " << lb << endl;
}
else if (choose == 4)
{
cout <<" Enter how many Grams: ";
cin >> g;
oz = g*0.035274;
cout << "Equivalent in Ounces is: " << oz << endl;
}
else if (choose == 5)
{
cout <<" Enter how many Liters: ";
cin >> lit;
gal = lit*0.26417;
cout << "Equivalent in Gallons is: " << gal << endl;
}
else if (choose == 6)
{
cout <<" Enter how many Metric Tons: ";
cin >> mt;
ton = mt*1.1023;
cout << "Equivalent in Tons is: " << ton << endl;
}
else if (choose == 7)
{
cout <<" Enter how many Millimeters: ";
cin >> mm;
in = mm*0.039370;
cout << "Equivalent in Inches is: " << in << endl;
}
else if (choose == 8)
{
cout <<" Enter how many Kilometers: ";
cin >> km;
mi = km*0.62137;
cout << "Equivalent in Miles is: " << mi << endl;
}
else
cout << "ERROR ERROR ERROR ERROR ERROR" << endl;
cout << "Do you want to return to first page?? (y/n)";
cin>> choice;
system("cls");
}while (choice != 'n');
return 0;
}

New Topic/Question
Reply



MultiQuote






|