3.1. [10 marks] Write a method with the following details:
3.2. [10 marks] Using the method below, write the statements to call the above method with the masses of the earth, moon and the distance between them and display the resulting force.
- Mass of Earth: 5.972E24
- Mass of Moon: 7.348E22
- Distance: 384,400,000 meters
- Answer: 1.99e020N - You should use “E” as a format specifier in your output (like when you use N, F, N2)
public const double G = 6.673e-11;
public static void Main()
{
var forceAttraction = CalculateGravitationalAttraction(5.972E24, 7.348E22
, 384400000);
Console.WriteLine(forceAttraction.ToString("E"));
}
public static double CalculateGravitationalAttraction(double mass1, double mass2, double distance) {
return G * (mass1 * mass2) / Math.Pow(distance, 2);
}
Comments
Leave a comment