im creating a program that converts centimeters to inches then to yards,feet,inches. i have been working on it forever and cant seem to get the program to give me the right answers. can anyone help.please????????????
-Matt
Heres the code:
#include <iostream>
using namespace std;
int main()
{
int cm, inch, ft, yd;
float temp;
cout<<"Please enter a length in centimeters " <<endl;
cin >>cm;
//calculate centimeters to inches
inch=cm/2.54+0.5;
//calculate inches to yards
yd = inch/36;
//calculate the remainder of yards to find feet.
temp = inch%36;
//calculate yards into feet
ft = temp/3;
//calculate feet into inches
inch = ft%12;
// output into yards, feet, inches
cout<<"The answer is: " <<yd <<" yards " <<ft <<" feet " <<inch <<" inches ";
return 0;
}
-Matt
Heres the code:
#include <iostream>
using namespace std;
int main()
{
int cm, inch, ft, yd;
float temp;
cout<<"Please enter a length in centimeters " <<endl;
cin >>cm;
//calculate centimeters to inches
inch=cm/2.54+0.5;
//calculate inches to yards
yd = inch/36;
//calculate the remainder of yards to find feet.
temp = inch%36;
//calculate yards into feet
ft = temp/3;
//calculate feet into inches
inch = ft%12;
// output into yards, feet, inches
cout<<"The answer is: " <<yd <<" yards " <<ft <<" feet " <<inch <<" inches ";
return 0;
}