/****************************************************************************** Lab Exercise #4 -- Implementation of support function ******************************************************************************/ using namespace std; #include #include void ConvertLength( double&, char, char ); /*----------------------------------------------------------------------------- Name: ConvertLength Purpose: Convert measurements from the English to the metric system Receive: A measurement, its unit in the English system, and the unit in the metric system for the conversion Return: The measurement in the metric system -----------------------------------------------------------------------------*/ void ConvertLength( double& Value, char In, char Out ) { double Centimeters; // Intermediate calculation -- length in centimeters switch (In) { // English unit is inches case 'I': Centimeters = Value * 2.54001; break; // English unit is feet case 'F': Centimeters = Value * 30.4801; break; // English unit is yards case 'Y': Centimeters = Value * 91.4402; break; // English unit is miles case 'M': Centimeters = Value * 160935.0; break; // English unit is not recognized default: cerr << "\n*** invalid English unit of measure ***\n\n"; Centimeters = DBL_MAX; break; } switch (Out) { // Metric unit is centimeters (NOT COMPLETED) case 'C': break; // Metric unit is meters (NOT COMPLETED) case 'M': break; // Metric unit is kilometers (NOT COMPLETED) case 'K': break; // Metric unit is not recognized default: cerr << "\n*** invalid metric unit of measure ***\n\n"; Value = DBL_MAX; break; } }