//File Name: Centimeter conversion program //Author: // //Narrative: This progra
ID: 3616408 • Letter: #
Question
//File Name: Centimeter conversion program
//Author:
//
//Narrative: This program is designed to prompt a user to inputa length
//in centimeters (cm) and then convert it to inches (in).Then
//the program will convert the length from the inches intoyards,
//feet and inches in that order and then display theresults.
//
//Input: The initial length in centimeters (cm)- lengthCenti-decimal
//
//Output: converted inches- conIn- decimal
//number of yards- numYd- decimal
//number of feet- numFt- decimal
//number of inches- numIn- decimal
//
//Constants: CENTIMETER = 0.393700787 inches
//YARD = 36 inches
//FOOT = 12 inches
//INCH = 1 inch
//
//Operation:
//1. prompt user for length in centimeters
//2. conIn is an integral part of CENTIMETER *lenghtCenti
//3. Display the number of inches in total
//4. numYd is an integral part conIn / YARD
//5. numYd = numYd - conIn / YARD
//6. numFt is an integral part of conIn /FOOT
//7. numFt = numFt - conIn / FOOT
//8. numIn is the remainder
//9. Display the output in the order of converted yards, feetand inches
#include <iostream>//forcin, cout
using namespace std;
const double CENTIMETER =0.393700787;
double YARD = 36,
FOOT = 1,
INCH = 1;
int main()
{
double lengthCenti,
conIn,
numYd,
numFt,
numIn,
remainder;
cout << "Please enter the length incentimeters: ",
cin >> lengthCenti;
conIn = CENTIMETER * lengthCenti;
numYd = conIn / YARD;
remainder = conIn % YARD;
numFt = remainder / FOOT;
numIn = remainder % FOOT;
cout << "lYour total measurement is" << numYd <<"yard(s) " <<numFt
<< "feet(foot) "<< numIn << "inch(es)"<< endl;
system ("pause");
return 0;
}
Explanation / Answer
//Operation:
//1. prompt user for length incentimeters
//2. conIn is an integral part ofCENTIMETER * lenghtCenti
//3. Display the number of inches intotal
//4. numYd is an integral partconIn / YARD
//5. numYd = numYd - conIn / YARD
//6. numFt is an integral part of conIn / FOOT
//7. numFt = numFt - conIn / FOOT
//8. numIn is the remainder
//9. Display the output in the order of converted yards,feet and inche
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.