Thursday, August 15, 2013

Length Conversion

using namespace std;

//declare constants

const double CENTIMETER_INCHES= 0.3945;

const double FOOT_INCHES= 12;

const double YARD_FEET=3;

int main()





{
 int centimeter;
 int inch,inchReminder;
 int foot;
 int yard;
 int footReminder;
 int yardReminder;

 //statement

 cout<<"Please enter the amount of centimeters:"<<endl;

 cin >> centimeter;

    cout<<endl;

 //calculate from centimeter to inches

 inch = centimeter * CENTIMETER_INCHES;

 //calculate from inch to foot

 foot = inch/12;
 inchReminder=inch%12;


 //calculate from foot to yard
 yard = foot/3;

 footReminder=foot%3;


 //display result





 cout<<yard<< "yards" <<footReminder<< "feet" <<inchReminder<< "inches" <<endl;


system("pause");
 return 0;

}

No comments:

Post a Comment