/* Qamarulhuda Khairullah */
/* EGR 126 Computer Programming for Engineers */
/* Dated: 11/1/2011 */
/*LAB # 3
Develop and run a C++ program to perform the following:
A. Present the user with a menu to select one of the following options:
1. Convert from Celsius to Fahrenheit
2. Convert from Fahrenheit to Celsius
3. Convert from pounds to kilograms
4. Convert from kilograms to pounds
9. EXIT */
cout << "Hello. Welcome to the Temperature Conversion program" << endl;
cout << "Enter any option"<<endl;
cout << "1.Convert from Celsius to Fahrenheit" <<endl;
cout << "2.Convert from Fahrenheit to Celsius" <<endl;
cout << "3.Convert from pounds to kilograms" <<endl;
cout << "4.Convert from kilograms to pounds" <<endl;
cin >> a;
do
{
cout << "Please enter the degrees in Celsius and press ENTER: " << endl;
cin >> Celsius;
Fahrenheit = ((9.0/5)*Celsius) + 32;
cout << " Degrees Fahrenheit = " << Fahrenheit << endl;
cin>>N ;
}
while (N==1);
do
{
cout << "Please enter the degrees in Fahrenheit and press ENTER: " << endl;
cin >> Fahrenheit;
Celsius = (5.0/9) * (Fahrenheit - 32);
cout << " Degrees Celsius = " << Celsius << endl;
cin>> N;
}
while (N==2);
do
{
cout << "Please enter the weight in pounds and press ENTER: " << endl;
cin >> lb;
Kilogram = 2.2 * lb;
cout << "Kilogram = " << Kilogram << endl ;
cin>>N;
}
while(N==3);
do
{
cout <<"Please enter the weight in Kilograms and press ENTER: " << endl;
cin >> Kilogram;
lb = Kilogram / 2.2 ;
cout << "Weight in Pounds = " << lb << endl;
cin>>N;
}
while(N==4);
Add a do ... while loop that begins before cout << "Enter any option"<<endl; and ends the last calculation: do { ... } while(a != 9); // You need to add the exit condition!