Answer to Question #330978 in C# for mandeep

Question #330978

3.1. [10 marks] Write a method with the following details: 

  • Name: CalculateGravitationalAttraction 
  • • Parameters: o A double representing the mass of the first body - name it "mass1" 
  • o A double representing the mass of the second body - name it "mass2" 
  • o A double representing the distance between them - name it "distance" 
  • Returns: A double representing the attractive force between the bodies 
  • Displays: Nothing 
  • Task: Calculate and return the force of attraction between them. Formula: o Force = G * (mass1 * mass2) / distance ^ 2 ▪ where G = 6.673e-11 (“G” should be a constant) 
  • ▪ for the power of 2 use Math.Pow() method 

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) 



1
Expert's answer
2022-04-20T03:44:59-0400

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);

}


Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS