I am having trouble with my looping sequence in this program at the end of the program it will let the user choose if they would like to exit the program or start all over again and it exits for both chooses and sometimes it will continue on to the next part of the program that the user does not choose. the program works perfectly besides that. Help plz.
Here is my code:
#include <iostream>
#include <cmath>
#include <string>
#include <cstring>
using namespace std;
int Option, Option1, convertchoice;
double feet1, feet, inchs, cm, meters, feetmeters, inchsCM;
void MATH()
{
feet1 = meters / 3.280839895;
inchs = cm / 2.54;
cout << "Alright the calculations are in!"<<endl;
cout << "you entered "<<meters<<" Feet, and you entered "<<cm<<" inches."<<endl;
cout << "So from meters to feet is "<<feet1<<" feet, and centimeters to inchesis "<<inchs<<" Centimeters"<<endl;
cout <<endl;
cout << "If you would like to try again please press 1, if you would like to exit please press 2"<<endl;
cin >> Option1;
}
void MATH1()
{
feetmeters = feet * 0.3048;
inchsCM = inchs * 2.54;
cout << "Alright the calculations are in!"<<endl;
cout << "you entered "<<feet<<" Feet, and you entered "<<inchs<<" inches."<<endl;
cout << "So from feet to meters is "<<feetmeters<<" Meters, and inches to centimeters is "<<inchsCM<<" Centimeters"<<endl;
cout <<endl;
cout << "If you would like to try again please press 1, if you would like to exit please press 2"<<endl;
cin >> Option1;
}
int main()
{
cout << "Hi, This program will be able to choose weither you would like to convert."<<endl;
cout << "inches and feet into centimeters and meters, or centimeters and meters into inches and feet"<<endl;
cout << "If you are ready begin please enter 1, if not enter 2 to leave the program."<<endl;
cin >> Option;
if(Option == 1)
{
while(Option1 == 2);
{
cout << "I see you are ready to begin!"<<endl;
cout << "Now you have a choice to choose which method in which you would like to convert into."<<endl;
cout << "If you would like to convert inches and feet into centimeters and meters, please enter 1"<<endl;
cout <<"If you would like to convert centimeters and meters into inches and feet, please enter 2"<<endl;
cin >> convertchoice;
if(convertchoice == 2)
{
cout << "Please Enter the lenght in meters of the object."<<endl;
cin >> meters;
cout << "Now enter the length in centimeters."<<endl;
cin >> cm;
MATH();
}
else convertchoice == 1;
{
cout << "Alright you have entered 1, lets begin!"<<endl;
cout << "Please Enter the lenght in feet of the object."<<endl;
cin >> feet;
cout << "Now enter the length in inches."<<endl;
cin >> inchs;
MATH1();
}
}
}
if(Option == 2)
{
return 0;
}
return 0;
}