void menu()
{
cout << "English Metric Junior" << endl;
cout << "1) convert from meters to feet" << endl;
cout << "2) convert from feet to meters" << endl;
cout << "3) compute the area of a rectangle in sqaure feet given length and width in meters" << endl;
cout << "4) compute the area of a rectangle in sqaure meters given length and width in feet" << endl;
cout << "5) quit the program" << endl;
cout <<" Please enter a number (1-5) -> "
}
\\ primarily down here
double Meters_to_Feet(double m, double f)
{
return m*f;
}
double feet_to_meters(double f, double m)
{
return f / m;
}
double Length_Width_Feet(double l, double w, double f)
{
return l*w*f;
}
double Length_Width_Meters(double l, double w, double m)
{
return l*w/m;
}
double f, m, l, w;
int choice;
cin >> choice;
do
{
menu();
switch (choice)
{
case 1:
cout << "enter meters: ";
cin >> m;
cout << "feet" << Meters_to_Feet(m,.3048) <<endl;
break;
case 2:
cout << "enter feet";
cin >> f;
cout << "meters" << feet_to_meters(f,.3048) <<endl;
break;
case 3:
cout << "enter length in meters";
cin >> l;
cout << "enter width in meters";
cin >> w;
cout << "square feet" << Length_Width_Feet(l,w,.3048) <<endl;
break;
case 4:
cout << "enter length in feet";
cin >> l;
cout << "enter width in feet";
cin >> w;
cout << "square meters" << Length_Width_Meters(l,w,.3048)<< endl;
break;
case 5:
break;
default:
cout << "please select (1-5) only" <<endl;
}while (choice =! 5);
return 0;
void menu();
cout << "English Metric Junior" << endl;
cout << "1) convert from meters to feet" << endl;
cout << "2) convert from feet to meters" << endl;
cout << "3) compute the area of a rectangle in sqaure feet given length and width in meters" << endl;
cout << "4) compute the area of a rectangle in sqaure meters given length and width in feet" << endl;
cout << "5) quit the program" << endl;
cout <<" Please enter a number (1-5) -> ";
void menu();
cout << "English Metric Junior" << endl;
cout << "1) convert from meters to feet" << endl;
cout << "2) convert from feet to meters" << endl;
cout << "3) compute the area of a rectangle in sqaure feet given length and width in meters" << endl;
cout << "4) compute the area of a rectangle in sqaure meters given length and width in feet" << endl;
cout << "5) quit the program" << endl;
cout <<" Please enter a number (1-5) -> ";
You had this section correct in your previous post. What happened?
int main()
{
double f, m, l, w;
int choice;
do
{
menu();
cin >> choice;
switch (choice)
{
case 1:
cout << "enter meters";
cin >> m;
cout << "feet" << Meters_to_Feet(m,.3048) <<endl;
break;
case 2:
cout << "enter feet ";
cin >> f; cout << "meters" << Feet_To_Meters(f,.3048) <<endl; \\ right here
break;
case 3:
cout << "enter length in meters";
cin >> l;
cout << "enter width in meters";
cin >> w;
cout << "sqaure feet " << Length_Width_Feet(l,w,.3048) <<endl;
break;
case 4:
cout << "Enter length in feet";
cin >> l;
cout << "enter width in feet";
cin >> w;
cout << "square meters" << Length_Width_Meters(l,w,.3048) <<endl;
break;
case 5:
break;
default:
cout << "Invalid input" << endl;
}
}while (choice != 5);
return 0;
}
void menu()
{
cout << "English Metric Junior" << endl;
cout << "1) convert from meters to feet" << endl;
cout << "2) convert from feet to meters" << endl;
cout << "3) compute the area of a rectangle in square feet given length and width in meters" << endl;
cout << "4) compute the area of a rectangle in square meters given the length and width in feet" << endl;
cout << "5) quit the program" << endl;
cout << "Please enter a number (1-5) ->";
}
double Meters_to_Feet(double m,double f)
{
return m * .3048;
}
double feet_to_meters(double f, float m)
{
return f / .3048;
}
double Length_Width_Feet(double l, double w, double m)
{
return l * w * .3048;
}
double Length_Width_Meters(double l, double w, double f)
{
return l * w / .3048;
}
Here we go: 4th time lucky. Please use code tags. http://www.cplusplus.com/articles/jEywvCM9/
You can edit your posts, highlight your code and click the <> button on the right.
okay I got every thing work except one little spot