/***************************************************************************** * Program: Inches to units converter * * Programmer: Dan Bennett * * Date Oct 3, 2001 * * * * This program prompts the user for a lenght in inches, it then * * calculates the length in inches, feet and yards * *****************************************************************************/ #include const int INCHESTOFEET=12; // conversion factor, inches to feet. const int FEETTOYARDS=3; // conversion factor, feet to yards. int main () { int invalue, // The value the user gives us and/or modified as we go inches, // calculated inches feet, // calculated feet yards; // calculated yards // get the initial length in inches and echo it back to the user. cout << "Enter a length in inches (integer only) " << endl; cin >> invalue; cout << "You entered a " << invalue << endl; // Calculate feet and inches inches = invalue % INCHESTOFEET; invalue = invalue / INCHESTOFEET; // Calculate the yards and feet feet = invalue % FEETTOYARDS; yards = invalue / FEETTOYARDS; cout << "That is the same as " << yards << " yards, " << feet << " feet, and " << inches << " inches." << endl; return(0); }