Question

In: Computer Science

The gravitational attractive force between two bodies with masses m1 and m2 separated by a distance...

The gravitational attractive force between two bodies with masses m1 and
m2 separated by a distance d is given by:
F = Gm1m2
d 2
where G is the universal gravitational constant:
G = 6.673 × 10−8 cm3
g × sec2
Write a function definition that takes arguments for the masses of two bod-
ies and the distance between them and that returns the gravitational force.
Since you will use the preceding formula, the gravitational force will be in
dynes. One dyne equals
g × cm
sec2
You should use a globally defined constant for the universal gravitational
constant. Embed your function definition in a complete program that
computes the gravitational force between two objects given suitable inputs.
Your program should allow the user to repeat this calculation as often as
the user wishes.

C++

the programming language is C++

Solutions

Expert Solution

Code -

#include <iostream>

using namespace std;
//constant declare for GRAVITATIONAL constant
const double GRAVITATIONAL = 6.6742E-8;

//FUNCTION TO CALCULATE Gravitational FORCE
double gravitationalForce(double mass1, double mass2, double distance){
//calculate Gravitational force
double gForce = (GRAVITATIONAL*mass1*mass2)/(distance*distance);
return gForce;
}
int main()
{
//variable declare
double gForce,mass1,mass2,distance;
//ask user for first body mass
cout<<"Enter mass of first body "<<endl;
cin>>mass1;
//ask user for second body mass
cout<<"Enter mass of second body "<<endl;
cin>>mass2;
//ask use for distance between 2 bodies
cout<<"Enter distance between 2 bodies "<<endl;
cin>>distance;
//calculate gravitational force
gForce = gravitationalForce(mass1,mass2,distance);
//print the result
cout<<"Gravitational Force between 2 bodies is "<<gForce;

return 0;
}

Screenshots -


Related Solutions

two masses m1 and m2 move under their mutual gravitation attraction in a uniform external gravitational...
two masses m1 and m2 move under their mutual gravitation attraction in a uniform external gravitational field whose acceleration is g. Choose as coordinates the cartesian coordinates X, Y, Z, of the center of mass (taking Z in the direction of g), the distance r between m1 and m2, and the polar angles θ and φ which specify the direction of the line from m1 to m2. Write expressions for the kinetic energy, the six forces Q_x, ... ,Q_φ and...
A collision occurs between two equal masses m1 and m2. Before the collision m2 is stationary....
A collision occurs between two equal masses m1 and m2. Before the collision m2 is stationary. After the collision both masses are moving differently. After the collision the position of the center of mass and motion of the center of mass respectively are best described as. ANSWER CHOICE A) halfway between the two masses, and stationary B) halfway between the two masses and moving C) halfway between the two masses and moving with the speed of mass m1 D) centered...
Derive an expression for the total number of stars between masses M1 and M2, where M1...
Derive an expression for the total number of stars between masses M1 and M2, where M1 < M2. Can the Salpeter IMF extend to arbitrarily low mass stars? Justify your answer quantitatively Derive an expression for the total mass in stars formed with masses between M1 and M2, where M1 < M2.
Two masses, m1 and m2, are falling but not freely. In addition to gravity, there is...
Two masses, m1 and m2, are falling but not freely. In addition to gravity, there is also a force F1 applied directly to m1 in the downward direction and a force F2 applied directly to m2 in the horizontal direction. Friction (µs) is present between the two masses and the forces are applied such that they do not rotate. The force F2 is as large as it can be and not have m2 slide relative to m1. (a) Find an...
two masses m1 = 4.70 kg and m2 which has a mass 50.0% that of m1,...
two masses m1 = 4.70 kg and m2 which has a mass 50.0% that of m1, are attached to a cord of negligible mass which passes over a frictionless pulley also of negligible mass. If m1 and m2 start from rest, after they have each traveled a distance h = 2.90 m, use energy content to determine the following. (a) speed v of the masses (b) magnitude of the tension T in the cord
1. Suppose we have two blocks of masses m1 and m2. The block with mass m1...
1. Suppose we have two blocks of masses m1 and m2. The block with mass m1 is moving towards block m2 at speed v. After the collision, we measure the total kinetic energy and find that the total kinetic energy after the collision is m2/(m1+m2) less than the kinetic energy before the collision. Find the final speeds of the two blocks. What type of collision is this? 2. Explain, in words, how we know that a freely spinning asteroid in...
Two objects with masses of m1 = 3.20 kg and m2 = 7.90 kg are connected...
Two objects with masses of m1 = 3.20 kg and m2 = 7.90 kg are connected by a light string that passes over a frictionless pulley, as in the figure below. A string passes over a pulley which is suspended from a horizontal surface. A circular object of mass m1 and a rectangular object of m2 are, respectively, attached to the left and right ends of the string. (a) Determine the tension in the string. N (b) Determine the acceleration...
Problem: Two blocks for masses m1 and m2 are stacked on top of each other and...
Problem: Two blocks for masses m1 and m2 are stacked on top of each other and placed on a frictionless, horizontal surface. The surfaces between two blocks is rough and has a coeff of static friction, us. A horiz push of magnitude, F, directed to the right is applied on the bottom block. A. Derive an expression for the maximum horizontal force, F, that can be applied on the bottom block, m1, before the top block m2, begins to slip....
1)What is the force between two equal charges (1 Coulomb) that are separated by a distance...
1)What is the force between two equal charges (1 Coulomb) that are separated by a distance of 1 km? 2)Suppose that the charge of one of the charges in problem #1 is reduced to half of its original value. How does the new force compare to the original force?
Two particles of equal masses m1=m2 move on a frictionless horizontal surface in the vicinity of...
Two particles of equal masses m1=m2 move on a frictionless horizontal surface in the vicinity of a fixed force center, with potential energies U1 = 1/2kr^(2)1 and U2 = 1/2kr^(2)2. In addition they interact with each other via a potential energy U12 = 1/2αkr^2 where r is the distance between them and α and k are positive constants. (a) Find the Lagrangian in terms of the CM position R and the relative position r. (b) Write down and solve the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT