C++ Programming

I NEED HELP WITH MY CODE!!! it won't compile right

The formula for finding the force of gravity between two objects is Force = grav * (mass1 * mass2) / (radius * radius), where Force = the force of gravity between the two objects, grav = the universal gravitation constant (6.67e-11), mass1 = the mass of the 1st object, mass2 = the mass of the second object, and radius = the distance between the centers of the two objects. Write a C++ program to allow the user to enter mass1, mass2 and the radius. The program should then calculate and display the force of gravity between the objects.

/* Universal Gravitation Program */
#include <iostream.h>
#include <stdlib.h>
int main ( )
double grav, mass1, mass2, radius, force;
cout << "Universal Gravitation" << endl;
cout << endl;
cout << "Enter mass1 (kg): ";
cin >> mass1;
cout << endl;
cout << "Enter mass2 (kg): ";
cin >> mass2;
cout << endl;
cout << "Enter radius (meters): ";
cin >> radius;
cout << endl;
grav = (6.67e - 11);
force = grav * (mass1 * mass2) / (radius * radius);
cout << "The force of gravity is : " << force << endl;
cout << endl;
cout << endl;
return (0);

  1. 👍
  2. 👎
  3. 👁

Respond to this Question

First Name

Your Response

Similar Questions

  1. Ed Tech

    What does the code of conduct include? A. A secret code for internet users B. The conduct that should be used with a code C. A set of rules for behavior when using the internet D. A rule that tells you the code I think C Thanks!

  2. Computer Literary

    Which of the following is Not an example of debugging A)Looking for errors in programming code B)Fixing misspelled commands in programming code C)Solving faulty logic in programming code D)Upgrading to improve the programming code

  3. Math

    The formula for finding the perimeter of an equilateral triangle is P = 3s. How can you transform the formula so that it can be used to determine the length of one side of the triangle when given the perimeter?

  4. AP Physics

    I'm trying to derive the formula v^2 = v0^2 + 2a(x-x0) were zeros are subscripts my book tells me to derive it this way use the definition of average velocity to derive a formula for x use the formula for average velocity when

  1. Math

    For each geometric series, calculate t6 and S6. a) 6 + 30 + 150 ... So I'm not exactly looking for an answer to this question but I was wondering why they want you to find t6 too? Would finding out t6 (via general formula) help in

  2. math

    Joyce is buying a pair of jeans for $39.99. The jeans are on sale at a 20% discount and the sales tax is 7%. Write a function T(x) to represent the total cost of an item with 7% sales tax. Find the composite function (T of

  3. Math

    What is the formula for finding the distance between two points on a coordinate plane? There are no answers for this I just need help cuz I can’t find the formula. If there are multiple formulas please give them to me please

  4. biology

    What can be said about mitochondria and its genetic code? Select all that apply. Mitochondria are unable to synthesize proteins using their genetic code. Mitochondrial proteins are made up of entirely different amino acids. The

  1. Math

    The formula V = Bh, where B represents the area of the base, can be used to find the volume of a cylinder. Which formula is equivalent to V = Bh when finding the cylinder's volume? A) V = (l · w) B) V = (l · w · h) C) V = πr2h

  2. History

    The Code Talkers were members of which Native American tribe? Apache Hopi Navajo******** Pueblo 2. Why was the Code Talkers' code so hard to break? It was based on a language that lacked an alphabet and was hard to learn. The

  3. math

    Find the linear block code generator matrix G, if the code generator polynomial is g(x) = 1 + x^3 for a (7,4) code.

  4. Physics

    A box of mass m = 59.0 kg (initially at rest) is pushed a distance d = 84.0 m across a rough warehouse floor by an applied force of FA = 204 N directed at an angle of 30.0° below the horizontal. The coefficient of kinetic

You can view more similar questions or ask a new question.