Circuit Negma

C++, C, VB.NET, PCB, Electronics, Circuit Design

inches, Feet to centimeters Converter

Posted by Circuit Negma on March 10, 2006


/*
 *  Copyright © 1997-2003 Metrowerks Corporation.  All Rights Reserved.
 *	
 *	Description: this program converts measurements in Feet and Inches
 *				 into centimerters using the approximation that
 *				 1 inch = 2.54 cn, 1 foot = 12 inches.
 *
 *	Created By: Circuit Negma
 *	Date	  : March 10, 2006
 */

	// Header File
#include <iostream>
#include <stdio.h>
using namespace std;

	// Declare Constants
const int feet_to_inches = 12;
const double inches_to_cn	 = 2.54;
	
	
int main()
{
	
	// Declare Variables
	int inches, feet;	// user input variables.
	int convFeet;		// Convert Feet to inches
	int total_inches;	// Total inches
	double result;		// Convert inches to centimeters
	
	// Ask user to enter data
	cout << "Please, enter an integer number of feets: ";
	cin	 >> feet;
	cout << "Please, enter an integer number of inches: ";
	cin	 >> inches;
	
	// Confirm data with the user
	cout << "You have entered " << feet << " Feet and " << inches << " inches \n";
	
	// Convert Feet to inches
	convFeet = feet_to_inches * feet;
	
	// Add convFeet to existing inches
	total_inches = convFeet + inches;
	
	// Convert total_inches to centimeters
	result = total_inches * inches_to_cn;
	
	// Print out the results
	cout << "You have a total of " << total_inches << " inches" << endl;
	cout << total_inches << " inches is equal to " << result << " cn";
	cout << endl << endl;
	
	return 0;
}


Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

 
%d bloggers like this: