/*************************************************/ // kilos.cpp // R. A. Hillyard/ / Last Modified: 02/07/2001 // // This program converts a weight given in kilograms (entered by the user) // into its equivalent in pounds and ounces // The relative conversion factors are: // 1 kilogram = 2.204623 pounds // 1 pound = 16 ounces /*************************************************/ #include <iostream>
using namespace std;
int main() { int pounds; float kilos; float totalLbs; float ounces; cout << "Enter weight in kilograms: "; cin >> kilos; totalLbs = kilos * 2.204623; pounds = totalLbs; ounces = 16 * (totalLbs - pounds); cout.setf(ios::fixed); //do not use e-notation cout.setf(ios::showpoint); //always show decimal point and trailing zeros cout.precision(2); //set number of decimal places cout << "\nThat converts to " << pounds << " pounds and " << ounces << " ounces\n"; return 0; } /**********************************************************************/ Enter weight in kilograms: 7.5 That converts to 16 pounds and 8.55 ounces /**********************************************************************/ Enter weight in kilograms: 88.3456 That converts to 194 pounds and 12.30 ounces