Ch2_ConvertLength - cout<<"Enter two integers one...

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 << "Enter two integers, one for feet and " << "one for inches: "; //Step 1 cin >> feet >> inches; //Step 2 cout << endl; cout << "The numbers you entered are " << feet << " for feet and " << inches << " for inches. " << endl; //Step 3 totalInches = INCHES_PER_FOOT * feet + inches; //Step 4 cout << "The total number of inches = " << totalInches << endl; //Step 5 centimeter = CENTIMETERS_PER_INCH * totalInches; //Step 6 cout << "The number of centimeters = " << centimeter << endl; //Step 7 return 0; }...
View Full Document

This note was uploaded on 03/08/2011 for the course CSIT 139 taught by Professor Duzut during the Spring '11 term at Los Angeles City College.

Ask a homework question - tutors are online