/* Algorithm prompt for distance in inches read in distance in inches. convert inches to yards, feet, inches. using mod and div convert inches into yards and inches. using the remaining inches, covert that to feet and inches the same way. print the fisrt result convert yards, feet, inches to inches yards * INCHES_PER_YARD + feet * INCHES_PER_FOOT + inches print the Check result */ /* scratch area 51 / 36 = 1 R 15 15 / 12 = 1 R 3 * */ #include using namespace std; const int INCHES_PER_YARD {36}; const int INCHES_PER_FOOT {12}; int main() { int inputInches {0}, finalInches {0}; int yards {0}, feet {0}, inches {0}; // prompt and read input cout << "Please enter a measurement in inches: "; cin >> inputInches; cout << endl; cout << inputInches << " is the same as:" << endl; // do the conversion yards = inputInches / INCHES_PER_YARD; inches = inputInches % INCHES_PER_YARD; feet = inches / INCHES_PER_FOOT; inches = inches % INCHES_PER_FOOT; cout << "\tYards:\t" << yards << endl; cout << "\tFeet:\t" << feet << endl; cout << "\tInches:\t" << inches << endl; // convert back or check. cout << "Check:" << endl; finalInches = yards * INCHES_PER_YARD + feet * INCHES_PER_FOOT + inches; cout << yards << " Yards " << feet << " Feet and " << inches << " inches is " << finalInches << " inches." << endl; return 0; }