Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Data about the planets is in the 4th photo. GEEN163 Planet Motion Write a progra

ID: 3821349 • Letter: D

Question


Data about the planets is in the 4th photo. GEEN163 Planet Motion Write a program that graphically displays the position ofthe four innerplanets as they orbit around the sun. In 1687, Isaac Newton formulated the principles governing the motion of two particles under the influence of their mutual gravitational attraction. Let Arrepresent the difference in the position of two planets, A& B, along the X coordinate and let Ay represent the difference along the Y coordinate. Calculate r, the distance between the two planets in meters,using The force in Newtons pulling the two planets together can be calculated using G. MA MB where MA and Ma are the mass of the two planets and G is the gravitational constant, 6.67 x 10 in the units N.m kg 2. The force can be divided into x and Y components by: F. Ay F. Ax Fx The force will accelerate the planet following Newton's second law of motion, F-ma. Over a small change in time, At, the velocity ofa planet is changed by velocityr At Fr velocity velocityy velocityx At Fr After calculating the change in velocity of a planet by all other planets, the position of the planet can be updated by X At velocity, Y Y At velocityr By repeating these calculations every At seconds, the planets will move under the gravitational force of the other planets, particularly the sun which is six orders of magnitude more massive than any of the planets. The program must first read in data about the planets. The input file, planets,txt, contains the position, velocity and mass of the sun and planets. Each line contains: X position of the planet in meters from the center Y position of the planet in meters from the center X direction velocity of the planet in meterssecond Y direction velocity of the planet in meterssecond Mass of the planet in Kg Suggested color for the planet (use is optional) Your program will need to create Planet objects to hold the information about each planet. The Planet object will need class instance variables for each ofthe data values on a line. It will need a constructor method to initialize these six values. 'idea from Robert Sedgewick and Kevin Wayme at Princeton University page I 3

Explanation / Answer

#include #define MAX 4 void main() { int array[MAX], i, largest1, largest2, temp; printf("Enter %d integer numbers ", MAX); for (i = 0; i