-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgravforce.cpp
More file actions
33 lines (22 loc) · 870 Bytes
/
Copy pathgravforce.cpp
File metadata and controls
33 lines (22 loc) · 870 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#include <iostream>
#include <cmath>
using namespace std;
int main() {
const double GRAVITY = 0.00000006673;
double mass1, mass2, dist;
double gravforce;
cout << "Enter the mass of the first object(in kg): ";
cin >> mass1;
cout << "Enter the mass of the second object(in kg): ";
cin >> mass2;
cout << "Enter the distance between the objects(in meters): ";
cin >> dist;
gravforce = ((GRAVITY * mass1 * mass2) / (dist * dist));
cout << "Results: " << endl;
cout << "The mass of the first object is: " << mass1 << "kg" << endl;
cout << "The mass of the second object is: " << mass2 << "kg" << endl;
cout << "The distance between the two objects is: " << dist <<" meters"<< endl;
cout << "The gravitational constant is: " << GRAVITY << " cm^3/(g * sec^2)" <<endl;
cout << "The gravitational force between the two objects is: " << gravforce <<endl;
return 0;
}