// Program file: metric.cpp // This program converts pounds to kilograms and inches to centimeters // using a struct object #include #include using namespace std; const float CM = 2.54; const float KG = 0.454; struct info_type { int height; int weight; float centimeters; float kilograms; }; info_type get_data(); void calc_height(info_type &i); void calc_weight(info_type &i); void print_results(info_type i); int main() { info_type infoObj; system("cls"); infoObj = get_data(); calc_height(infoObj); calc_weight(infoObj); print_results(infoObj); system("pause"); return 0; } info_type get_data() { info_type i; cout << "Enter your height in inches: "; cin >> i.height; cout << "Enter your weight in pounds: "; cin >> i.weight; return i; } void calc_height(info_type &i) { i.centimeters = i.height * CM; } void calc_weight(info_type &i) { i.kilograms = i.weight * KG; } void print_results(info_type i) { 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) << i.height << "in. " << setw(6) << i.weight << "lbs." << endl; cout << "Metric " << setw(6) << i.centimeters << "cm. " << setw(6) << i.kilograms << "kg." << endl; }