The file compiles correct, I just want to make sure i assigned the function and variables correctly because when i run the program, the output is always 0 reguardless of the inputted numbers.
Code:
#include <iostream>#include <cmath>
using namespace std;
const double G = 6.673 * pow ( 10, -8 );
int main ()
{
double value_1, value_2, distance, gravitational_force;
char response='y';
while (response == 'y' || response == 'y')
{
cout << "Welcome to the Gravitational Force program." << endl;
cout << endl;
{
cout << "Please enter the mass of the first object: ";
cin >> value_1;
cout << endl;
cout << "Please enter the mass of the second object: ";
cin >> value_2;
cout << endl;
cout << "Please enter the distance between the two objects: ";
cin >> distance;
cout << endl;
int gravitational_force = ( G * value_1 * value_2 ) / pow ( distance , 2 );
cout << "The gravitation force between the two objects is ";
cout << gravitational_force;
cout << " dynes.";
cout << endl;
}
cout << "Would you like to run the program again? (Y for yes, anything else for no) ";
cin >>response;
}
return 0;
}