English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

Im missing some of the formulas. What i have is giving me the wrong numbers. if u put in 5289 it should return 57 yards 6 inches 2 feet

2006-10-11 18:18:01 · 3 answers · asked by Ryan G 1 in Computers & Internet Programming & Design

#include
#include
using namespace std;

int main()
{

int yards,inches,cent,inch;
int feet,ft,yd;

inches = cent/2.54;
feet = int(inch/12);
inches-(feet*12);
yards = int(feet/3);
feet=feet-(yards*3);



cout<< "Enter an interger value that will represent centimeters: ";
cin >> cent;

cout << cent< "and"<
cout<< "Thank You!"<



system("pause");
return 0;

}
this is what i used so far but its not giving me 57 yards 2 inches and 6 feet when i put in 5289 centimeters

2006-10-12 09:33:36 · update #1

3 answers

Okay. First, it sounds like it may be reversing inches and feet with the way your result is written. My advice would be to convert the cm to inches first to lose the metric system entirely. This conversion factor is 1 inch = 2.54 cm. So, divide your cm by 2.54 to get inches. If you need more precision, go to the website below and change the number of decimal places. Now, 1 foot = 12 inches and 1 yard = 3 feet. I would convert the inches to feet then convert the feet to yards. The code could look something like this.

/*cm represents centimeters, inch represents inches, ft represents feet, yd represents yards*/
inch = cm / 2.54;
ft = int(inch / 12);
inch = inch - (ft * 12);
yd = int(ft / 3);
ft = ft - (yd * 3);

I'll leave the input and output coding for you, but, this should solve your formula problems. It's been a while since I coded something like this. You may need to include the math.h header file to use the int() function.

2006-10-11 18:30:38 · answer #1 · answered by iuneedscoachknight 4 · 0 0

Easy!

http://www.teaching-english-in-japan.net/conversion/pounds

2006-10-11 18:22:22 · answer #2 · answered by Phantom Sky 2 · 1 0

how about you write the code and we error check it?

2006-10-11 18:21:36 · answer #3 · answered by Chris™ 5 · 0 0

fedest.com, questions and answers