Polpak/Amistre/Imran/Joemath/Myininaya/Estudier/any other programming/math guru, can you take a look at my source code and see if everything is right?
Everything is working fine, but my conversion are different from the professors..
#include<iostream> #include<cmath> #include<iomanip> using namespace std; int main() { double w, m, a_yrs, a_days_on_Earth; cout << "Please enter your weight (lbs):\n"; cin >> w; m=w/9.81; cout <<"\n"; cout << "Please enter your age (years):\n"; cin >> a_yrs; a_days_on_Earth=a_yrs*365; double g_Me=3.59, g_Ve=8.87, g_Mo=1.62, g_Ma=3.77, g_Ju=25.95, g_Sa=11.08, g_Ur=10.67, g_Ne=14.07; double y_Me=88, y_Ve=224.7, y_Mo=365, y_Ma=686.961, y_Ju=4331.572, y_Sa=10832.327, y_Ur=30799.095, y_Ne=60190; double w_Me=m*g_Me, w_Ve=m*g_Ve, w_Mo=m*g_Mo, w_Ma=m*g_Ma, w_Ju=m*g_Ju, w_Sa=m*g_Sa, w_Ur=m*g_Ur, w_Ne=m*g_Ne; double a_Me=a_days_on_Earth/y_Me, a_Ve=a_days_on_Earth/y_Ve, a_Mo=a_days_on_Earth/y_Mo, a_Ma=a_days_on_Earth/y_Ma, a_Ju=a_days_on_Earth/y_Ju, a_Sa=a_days_on_Earth/y_Sa, a_Ur=a_days_on_Earth/y_Ur, a_Ne=a_days_on_Earth/y_Ne; cout <<"\n"; cout << left << setw(11) <<"Planet Weight" << right << setw(11) << "Age\n" <<"------ ------ ---\n"; cout <<"Mercury "<<w_Me<<" lbs"; cout <<" "<<a_Me<<" yrs"<<"\n"; cout <<"Venus "<<w_Ve<<" lbs"; cout <<" "<<a_Ve<<" yrs"<<"\n"; cout <<"Moon "<<w_Mo<<" lbs"; cout <<" "<<a_Mo<<" yrs"<<"\n"; cout <<"Mars "<<w_Ma<<" lbs"; cout <<" "<<a_Ma<<" yrs"<<"\n"; cout <<"Jupiter "<<w_Ju<<" lbs"; cout <<" "<<a_Ju<<" yrs"<<"\n"; cout <<"Saturn "<<w_Sa<<" lbs"; cout <<" "<<a_Sa<<" yrs"<<"\n"; cout <<"Uranus "<<w_Ur<<" lbs"; cout <<" "<<a_Ur<<" yrs"<<"\n"; cout <<"Neptune "<<w_Ne<<" lbs"; cout <<" "<<a_Ne<<" yrs"<<"\n"; system("pause"); return 0; }
im not a guru, im only a Superhero =/
Doesn't matter joe, u're a guru for me, all yall haha
hmm that looks ugly.. I can attach .cpp and .exe files..
I didn't think you divided pounds by g to get mass? Mixing up units.
yea I did. Look at the variable declaration statement: cout << "Please enter your weight (lbs):\n"; cin >> w; m=w/9.81; from then on I'm working with mass
But that's if you have Newtons.
Okay look weight is mass * gravity So on earth: M = weight/gravity m=w/9.8 So I get the actual mass of the person. Then I redo: w_Ve=m*g_Ve So that's the m*g on venus
I know that. I'm saying you are using pounds which is not an SI unit.
And using 9.81 which is in SI units.
Ohh THATS WHY IM SO OFFF!!! THanks!!!
How many pounds are in a kilogram?
Google it. ;)
lol too lazy, but I will.. ughh americans and englishmen.. why did they have to make our lives so complicated.
1 kilogram = 2.20462262 pounds
That's what we call a logical error in computer science. ;)
Yea I kno I just googled it haha
anyway hold up, let me fix the code..
oh snap now I have to convert it back to lbs.. HOLY MOLY!!!
LOL I was actually closer to the right answer when I didn't convert anything, was only off for two planets.
actually doing that was stupid, I am displaying the output in lbs not kgs. So I ended up converting it to kgs and back to lbs and still had the same numbers.
So it's still wrong?
Yea... take a look, I'm write for some numbers, wrong for some others. All the ages on diff planets are right, but the weights.. nope.. hold up ima attach a file
here take a look
meant *right not write haha
m = w/2.2 will give you kg
no mkuehn I already did that, I got it in kgs, then at the end i multiplied the result by 2.2 to get lbs.. and ended up getting the same thing
so the result was like multiplying by one
Where did you get your g values for the planets?
Why don't you use the ratio of g / g-Earth instead? You wouldn't have to do any conversions then, just multiply by that ratio to get the weight on the other planet.
"Since we now know the acceleration due to gravity on different worlds, we can easily determine how much an object weighs on those bodies. We have shown that the value of "g" on the Moon is 1/6th that of Earth, so an object on the Moon weighs only 1/6th as much as it would on Earth. A person weighing 150 pounds on Earth, for example, would weigh only 25 pounds on the Moon."
hold on, let me just check something, ill post a new thread.
Join our real-time social learning platform and learn together with your friends!