// Program file: metricClass.cpp // This program converts pounds to kilograms and inches to centimeters // using a simple class object #include #include using namespace std; class Metric { public: static const float CM = 2.54; static const float KG = 0.454; int height; int weight; float centimeters; float kilograms; }; Metric get_data(); void calc_height(Metric &m); void calc_weight(Metric &m); void print_results(Metric m); int main() { Metric metricObj; system("cls"); metricObj = get_data(); calc_height(metricObj); calc_weight(metricObj); print_results(metricObj); system("pause"); return 0; } Metric get_data() { Metric m; cout << "Enter your height in inches: "; cin >> m.height; cout << "Enter your weight in pounds: "; cin >> m.weight; return m; } void calc_height(Metric &m) { m.centimeters = m.height * m.CM; } void calc_weight(Metric &m) { m.kilograms = m.weight * m.KG; } void print_results(Metric m) { cout << setprecision(2) << setiosflags(cout.fixed) << setiosflags(cout.showpoint); cout << "YOUR HEIGHT AND WEIGHT IN CENTIMETERS AND KILOGRAMS"; cout << endl << endl; cout << " Height Weight" << endl; cout << "--------------------------------------" << endl; cout << "English " << setw(6) << m.height << "in. " << setw(6) << m.weight << "lbs." << endl; cout << "Metric " << setw(6) << m.centimeters << "cm. " << setw(6) << m.kilograms << "kg." << endl; }