Ch2_ConvertLength - cout <<...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
//******************************************************** // Program Convert Measurements: This program converts // measurements in feet and inches into centimeters using // the formula that 1 inch is equal to 2.54 centimeters. //******************************************************** / //header file #include <iostream> # using namespace std; u //named constants const double CENTIMETERS_PER_INCH = 2.54; const int INCHES_PER_FOOT = 12; c int main () { //declare variables int feet, inches; int totalInches; double centimeter; //Statements: Step 1 - Step 7
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: cout &lt;&lt; &quot;Enter two integers, one for feet and &quot; &lt;&lt; &quot;one for inches: &quot;; //Step 1 cin &gt;&gt; feet &gt;&gt; inches; //Step 2 cout &lt;&lt; endl; cout &lt;&lt; &quot;The numbers you entered are &quot; &lt;&lt; feet &lt;&lt; &quot; for feet and &quot; &lt;&lt; inches &lt;&lt; &quot; for inches. &quot; &lt;&lt; endl; //Step 3 totalInches = INCHES_PER_FOOT * feet + inches; //Step 4 cout &lt;&lt; &quot;The total number of inches = &quot; &lt;&lt; totalInches &lt;&lt; endl; //Step 5 centimeter = CENTIMETERS_PER_INCH * totalInches; //Step 6 cout &lt;&lt; &quot;The number of centimeters = &quot; &lt;&lt; centimeter &lt;&lt; endl; //Step 7 return 0; }...
View Full Document

Ask a homework question - tutors are online