03 Functions and Procedures

03 Functions and - Click to edit Master subtitle style Engineering 101 Functions and Procedures Quote of the Day Confucius Even when walking in the

Info iconThis preview shows pages 1–13. Sign up to view the full content.

View Full Document Right Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: Click to edit Master subtitle style Engineering 101 Functions and Procedures Quote of the Day- Confucius Even when walking in the company of two others, I am bound to be able to learn from them. The good points of the one I copy; the bad points of the other I correct in myself. Your Weight on Mars n Your Weight is the force exerted on you n The Universal Law of Gravitation States n Your weight on earth is 2 R GmM W = mg W E = R=rad ius M=planet mass m=your mass G=6.672x10- Your Weight on Mars n So the ratio of your weight on another planet to your weight on earth is n So if I know the mass of the planet, M, and the radius of the planet, R, I can find the change in my weight. ( 29 2 12 2 2 10 8 . 6 R M gR GM W W s m E- × = = What do we want What is your weight on earth? 165 Weight on Mars is 62.5 Start with the scaffolding #include <iostream> using namespace std; int main( ){ Add the Obvious Expresssions #include <iostream> using namespace std; int main( ){ cout << “What is your weight on earth?” << endl; cin >> earthweight; cout << “Weight on mars is ” << marsratio*earthweight << endl; Make sure to add declarations #include <iostream> using namespace std; int main( ){ double marsmass = 6.4e23; double marsrad = 3.4e6; double earthweight; double marsratio; cout << “What is your weight on earth?” << endl; cin >> earthweight; cout << “Weight on mars is ” << marsratio*earthweight << endl; Add in the equation #include <iostream> using namespace std; int main( ){ double marsmass = 6.4e23; double marsrad = 3.4e6; double earthweight; double marsratio; cout << “What is your weight on earth?” << endl; cin >> earthweight; marsratio = 6.8e-12*marsmass/(marsrad*marsrad); cout << “Weight on mars is ” << marsratio*earthweight << endl; Add comments for the reader #include <iostream> // Program written by someone using namespace std; // This computes your weight int main( ){ // if you happen to be on Mars double marsmass = 6.4e23; // The mass of Mars double marsrad = 3.4e6; // The radius of Mars double earthweight; // The weight on Earth double marsratio; // Ratio of Mars to Earth cout << “What is your weight on earth?” << endl; cin >> earthweight; // compute the weight of the person on Mars marsratio = 6.8e-12*marsmass/(marsrad*marsrad); cout << “Weight on mars is ” << marsratio*earthweight << endl; What if… n …you wanted to add in your weight on Jupiter too? #include <iostream> // Program written by someone using namespace std; // This computes your weight int main( ){ // if you happen to be on Mars or Jupiter double marsmass = 6.4e23; // The mass of Mars...
View Full Document

This note was uploaded on 04/07/2010 for the course ENGR engr 101 taught by Professor Rinenberg during the Spring '10 term at University of Michigan.

Page1 / 84

03 Functions and - Click to edit Master subtitle style Engineering 101 Functions and Procedures Quote of the Day Confucius Even when walking in the

This preview shows document pages 1 - 13. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online