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)
2 answers
so what is your question on this assignment? Surely you do not want someone to write the code for you.
if category = "length" then
if inunit = "inch" then
outunit = "centimeter"
outamt = inamt * 2.54
elseif inunit = ...
...
endif
elseif category = "weight" then
...
endif
kinda klunky, but it does the job.
Just fill in all the other possibilities.
if inunit = "inch" then
outunit = "centimeter"
outamt = inamt * 2.54
elseif inunit = ...
...
endif
elseif category = "weight" then
...
endif
kinda klunky, but it does the job.
Just fill in all the other possibilities.