This is a C++ programme to calculate your weight on different planets and also your weight on unknown planets or heavenly bodies if you enter their radius and mass.
void get_mass() { cout<<"What's your weight on weighing machine? "; cin>>machine_weight; mass=machine_weight/9.8; //dividing weighing machine weight by acceleration due to gravity on earth }
void moon() { planet_weight=mass*1.6; // g(moon)=1.6 cout<<"Your weight on Moon is "<<planet_weight<<endl; }
void unknown_planet() { cout<<"Enter Radius of the planet"; cin>>radius; cout<<"Enter Mass of the planet"; cin>>mass_of_planet; planet_weight=((G*mass_of_planet*mass)/(radius*radius)); cout<<"Your weight on this planet is "<<planet_weight<<endl;
}
Submitted by Srishti Dhaval Patkar (srishtipatkar15)
Download packets of source code on Coders Packet
Comments