Using the if… else if, write a menu-driven program that permits the user to select one of the metric conversions: Lengths Weights Volumes Areas Use the following conversions:

For Length: Inches to centimeter (1 inch = 2.54 cm) Yards to meters (1 yard = 0.9144 m) Miles to kilometers (1 mile = 1.609344 km)
For Weights: Ounces to grams (1 ounce = 28.349523 g) Pounds to kilograms (1 pound = 0.453592 kg) Tons to kilograms (1 ton = 907.18474 kg)
For Volumes: Pints to liters (1 pint = 0.473163 l) Quarts to liters (1 quart = 0.946326 l) Gallons to liters (1 gallon = 3.785306 l)
For Areas: Square inches to square millimeters (1 sq. in. = 645.16 sq.mm) Square feet to square meters (1 sq. foot = 0.09290304 sq.m) Acres to square meters (1 Acre = 4.04686x10^3 sq.m)
The question is how can I write a Programming using if ....else if.?

#include <iostream>

#include <cmath>
using namespace std;

int main ()
{
int Length= 1, Weight= 2, Volume=3;
int cm, m, km, mm2, m2, pt, qt, gal,g, kg;
int Choice;
long double inch= 2.54, yard= 0.9144, mile = 1.609344;
long double ounce= 28.349523, pound= 0.453592, ton = 907.18474;
long double pints= 0.473163, quart= 0.946326, gallon = 3.785306;
long double in2= 645.16, ft2= 0.09290304, Acre = (4.04686e3);
double a, b, c;
char MS= 'x';

cout<<"Metric System"<<endl;
cout<<"(L) Length"<<endl;
cout<<"(W) Weight"<<endl;
cout<<"(V) Volume"<<endl;
cout<<"(A) Area"<<endl;

cout<<"Which Metric System will you use? ";
cin>> MS;

Length= 'L'==MS;
Weight= 'W'==MS;
Volume= 'V'==MS;


if (Length)
{cout<<"LENGTHS"<<endl;cout<<"1) Iches to Centimeter"<<endl;
cout<<"2) Yards to Meters"<<endl;
cout<<"3) Miles to Kilometers"<<endl;
cout<<"Enter your choice: ";
cin>>Choice;
cout<<endl;

if (Choice==1)
{cout<<"Convert Inches to Centimeters"<<endl;
cout<<"Enter value in inches: "; cin>>cm;cout<<endl;

a=cm*inch;
cout<<cm<<" Inches = "<<a<<" Centimeters"<<endl;
}
else if (Choice==2)
{cout<<"Convert Yards to Meters"<<endl;
cout<<"Enter value in yards: ";cin>>m;cout<<endl;

b=m*yard;
cout<<m<<" yards = "<<b<<" meters"<<endl;
}
else
{cout<<"Convert Miles to Kilometers"<<endl;
cout<<"Enter value in miles: ";cin>>km;

c=km*mile;
cout<<km<<" mile = "<<c<<" kilometers"<<endl;
}
}
else if (Weight)
{cout<<"WEIGHTS"<<endl;
cout<<"1) Ounces to Grams"<<endl;
cout<<"2) Pounds to Kilograms"<<endl;
cout<<"3) Tons to Kilograms"<<endl;
cout<<"Enter your choice: ";
cin>>Choice;
cout<<endl;

if (Choice==1)
{cout<<"Convert Ounces to Grams"<<endl;
cout<<"Enter value in ounces: "; cin>>g; cout<<endl;

a=g*ounce;
cout<<g<<" ounces = "<<a<<" grams"<<endl;
}
else if (Choice==2)
{cout<<"Convert Pounds to Kilograms"<<endl;
cout<<"Enter value in pounds ";cin>>kg; cout<<endl;

b=kg*pound;
cout<<kg<<" pounds = "<<b<<" Kilograms"<<endl;
}
else
{cout<<"Convert Tons to Kilograms"<<endl;
cout<<"Enter value in tons: "; cin>>kg; cout<<endl;

c=kg*ton;
cout<<kg<<" tons = "<<c<<" Kilograms"<<endl;
}
}

else if (Volume)
{cout<<"VOLUMES"<<endl;
cout<<"1) Pints to Liters"<<endl;
cout<<"2) Quarts to Liters"<<endl;
cout<<"3) Gallons to Liters"<<endl;
cout<<"Enter your choice: ";
cin>>Choice;
cout<<endl;

if (Choice==1)
{cout<<"Convert Pints to Liters"<<endl;
cout<<"Enter value in pints: "; cin>>pt; cout<<endl;

a=pt*pints;
cout<<pt<<" pints = "<<a<<" Liters"<<endl;
}
else if (Choice==2)
{cout<<"Convert Quarts to Liters"<<endl;
cout<<"Enter value in quarts: ";cin>>qt; cout<<endl;

b=qt*quart;
cout<<qt<<" quarts = "<<b<<" liters"<<endl;
}
else
{cout<<"Convert Gallons to Liters"<<endl;
cout<<"Enter value in Gallons: ";cin>>gal; cout<<endl;

c=gal*gallon;
cout<<gal<<" gallons = "<<c<<" liters"<<endl;
}
}
else
{cout<<"AREAS"<<endl;
cout<<"1) Square inches to square millimeters"<<endl;
cout<<"2) Square feet to square meters"<<endl;
cout<<"3) Acres to square meters"<<endl;
cout<<"Enter your choice: ";
cin>>Choice;
cout<<endl;

if (Choice==1)
{cout<<"Convert Square inches to square millimeters"<<endl;
cout<<"Enter value in Square inches: "; cin>>mm2; cout<<endl;

a=mm2*in2;
cout<<mm2<<" Square Inches = "<<a<<" Square millimeters"<<endl;
}
else if (Choice==2)
{cout<<"Convert Square feet to square meters"<<endl;
cout<<"Enter value in Square feet: ";cin>>m2;cout<<endl;

b=m2*ft2;
cout<<m2<<" square feet = "<<b<<" square meters"<<endl;
}
else
{cout<<"Convert Acres to square meters"<<endl;
cout<<"Enter value in Acres: ";cin>>m2;

c=m2*Acre;
cout<<m2<<" acres = "<<c<<" square meters"<<endl;
}
}

return 0;
}

if (condition) {

...
} else if (condition) {
...
}

To write a menu-driven program using if...else if statements, you can follow these steps:

1. Display the menu options to the user.
2. Prompt the user to enter their choice.
3. Use if...else if statements to check the user's choice and execute the corresponding conversion code.

Here's an example of how you can write the program in a high-level language, such as Java:

```java
import java.util.Scanner;

public class MetricConversion {
public static void main(String[] args) {
Scanner scanner = new Scanner(System.in);
int choice;

// Display menu options
System.out.println("Metric Conversions Menu:");
System.out.println("1. Lengths");
System.out.println("2. Weights");
System.out.println("3. Volumes");
System.out.println("4. Areas");

// Prompt for user's choice
System.out.print("Enter your choice: ");
choice = scanner.nextInt();

// Perform conversions based on the user's choice
if (choice == 1) {
// Length conversions
System.out.println("Length Conversions Menu:");
System.out.println("1. Inches to centimeter");
System.out.println("2. Yards to meters");
System.out.println("3. Miles to kilometers");

System.out.print("Enter your choice: ");
int lengthChoice = scanner.nextInt();

if (lengthChoice == 1) {
// Inches to centimeter conversion
System.out.print("Enter inches: ");
double inches = scanner.nextDouble();
double centimeter = inches * 2.54;
System.out.println(inches + " inches = " + centimeter + " centimeters.");
} else if (lengthChoice == 2) {
// Yards to meters conversion
System.out.print("Enter yards: ");
double yards = scanner.nextDouble();
double meters = yards * 0.9144;
System.out.println(yards + " yards = " + meters + " meters.");
} else if (lengthChoice == 3) {
// Miles to kilometers conversion
System.out.print("Enter miles: ");
double miles = scanner.nextDouble();
double kilometers = miles * 1.609344;
System.out.println(miles + " miles = " + kilometers + " kilometers.");
} else {
System.out.println("Invalid choice for length conversions.");
}
} else if (choice == 2) {
// Weight conversions
// Implement weight conversions in a similar way
} else if (choice == 3) {
// Volume conversions
// Implement volume conversions in a similar way
} else if (choice == 4) {
// Area conversions
// Implement area conversions in a similar way
} else {
System.out.println("Invalid choice for metric conversions.");
}

scanner.close();
}
}
```

This program uses nested if...else if statements to handle choices for different conversions based on the user's selection. You can extend the program to include the remaining conversions by adding more else if blocks within each category.