You are on page 1of 6

A

Project Report on
Gravitational Force Calculator using c++

submitted for partial fulfillment of computer science practical


examination +2 Non-Medical conducted

by

Punjab School Education Board

Name : Name Here

Roll No : { Roll Number Here }

{School Name Here}


Introduction

Universal Law of Gravitation

Every object in the universe attracts every other object with a force which is
proportional to the product of their masses and inversely proportional to the
square of the distance between them. The force is along the line joining the
centres of two objects.

Fig.1

Let two objects A and B of masses M and m lie at a distance d from each other as
shown in Fig. 1.. Let the force of attraction between two objects be F. According to the
universal law of gravitation, the force between two objects is directly proportional to
the product of their masses. That is,

F M*m ----------
(1)

And the force between two objects is inversely proportional to the square of the
distance between them, that is,

F α 1 ⁄ d2 ---------- (2)

Combining Eqs. (1) and (2), we get


F α M x m ⁄ d2 ---------- (3)

or, F = G( (M x m) ⁄ d2) ---------- (4)

where G is the constant of proportionality and is called the universal gravitation


constant. By multiplying crosswise, Eq. (4) gives

F×d 2
=GM×m

or G = F d 2/ M m ---------- (5)

The SI unit of G can be obtained by substituting the units of force, distance and mass in
Eq. (5) as N m2 kg–2.

The value of G was found out by Henry Cavendish (1731 – 1810) by using a sensitive
balance. The accepted value of

G is 6.673 × 10–11 N m2 kg–2.

We know that there exists a force of attraction between any two objects. Compute the
value of this force between you and your
friend sitting closeby. Conclude how you do not experience this force!

Importance of the Universal Law of Gravitation.

The universal law of gravitation successfully explained several phenomena which were
believed to be unconnected:

1. the force that binds us to the earth;


2. the motion of the moon around the earth;
3. the motion of planets around the Sun; and
4. the tides due to the moon and the Sun.
Program / Source Code
#include <iostream.h>
#include <conio.h>
#define G 6.67E-11
class GFCalculator
{
private:
float m1,m2;
float r,f;
//m1,m2 mass of two objects in kg
//r is distance betwween two objects
//f is force of attraction between two objects in
public:
GFCalculator()
{ m1=0;m2=0;}
void readmass()
{
cout<<"Enter mass of first object in Kg : ";cin>>m1;
cout<<"Enter mass of second object in Kg : ";cin>>m2;
}
void readdistance()
{
cout<<"Enter distance between two objects in meter :
";cin>>r;
}
void calc_and_disp_info()
{
f=G*m1*m2/(r*r);
cout<<endl<<endl<<endl;
cout<<"Gravitatinal Constant : "<<G<<" cubic
meter/kg/sec square"<<endl;
cout<<"M1 : "<<m1<<" Kg"<<endl;
cout<<"M2 : "<<m2<<" Kg"<<endl;
cout<<"Distance : "<<r<<" meter"<<endl;
cout<<"Gravitational force : "<<f<<" Newton";
}
};
void main()
{
GFCalculator GF;
clrscr();
GF.readmass();
GF.readdistance();
GF.calc_and_disp_info();
getch();
}

Output

You might also like