top of page
  • kentra52

Newton's Law of Gravitation

What is the gravitational force in Newtons between the Earth and the Moon? Write the calculation in Java, C# and Python using the respective Caliper libraries.

 

In Java:

MeasurementSystem sys = MeasurementSystem.getSystem();

UnitOfMeasure gUOM = sys.getUOM(Unit.NEWTON_METRE).multiply(sys.getUOM(Unit.METRE)).divide(sys.createPowerUOM(sys.getUOM(Unit.KILOGRAM), 2));

Quantity G = new Quantity(6.743015E-11, gUOM);

Quantity mEarth = new Quantity(5.96E24, sys.getUOM(Unit.KILOGRAM));

Quantity mMoon = new Quantity(7.33E22, sys.getUOM(Unit.KILOGRAM));

Quantity distance = new Quantity(3.84E08, sys.getUOM(Unit.METRE));

Quantity force = G.multiply(mEarth).multiply(mMoon).divide(distance.multiply(distance));

 

In C#:

MeasurementSystem sys = MeasurementSystem.GetSystem();

UnitOfMeasure gUOM = sys.GetUOM(Unit.NEWTON_METRE).Multiply(sys.GetUOM(Unit.METRE)).Divide(sys.CreatePowerUOM(sys.GetUOM(Unit.KILOGRAM), 2));

Quantity G = new Quantity(6.743015E-11, gUOM);

Quantity mEarth = new Quantity(5.96E24, sys.GetUOM(Unit.KILOGRAM));

Quantity mMoon = new Quantity(7.33E22, sys.GetUOM(Unit.KILOGRAM));

Quantity distance = new Quantity(3.84E08, sys.GetUOM(Unit.METRE));

Quantity force = G.Multiply(mEarth).Multiply(mMoon).Divide(distance.Multiply(distance));

 

In Python:

msys = MeasurementSystem.instance()

gUOM = msys.getUOM(Unit.NEWTON_METRE).multiply(msys.getUOM(Unit.METRE)).divide(msys.createPowerUOM(msys.getUOM(Unit.KILOGRAM), 2))

G = Quantity(6.743015E-11, gUOM)

mEarth = Quantity(5.96E24, msys.getUOM(Unit.KILOGRAM))

mMoon = Quantity(7.33E22, msys.getUOM(Unit.KILOGRAM))

distance = Quantity(3.84E08, msys.getUOM(Unit.METRE))

force = G.multiply(mEarth).multiply(mMoon).divide(distance.multiply(distance))

5 views0 comments

Recent Posts

See All

What is a Perm?

A perm is a unit of permeance or "water vapor transmission" given differences in partial pressures on two sides of a membrane or material. It is commonly used in building science as a measure of how

Comentários


bottom of page