[Solved] CPP Assignment 4

30 $

File Name: CPP_Assignment_4.zip
File Size: 150.72 KB

SKU: [Solved] CPP Assignment 4 Category: Tag:

Or Upload Your Assignment Here:


In general always write your name and date of creation as comments in the files andtry to be “user friendly” when you write the code:● Add comments on the code to remember yourself and the other whatthe code does● Manage the possible errors in the input given by the userThe 70% of this assignment is everything a part from point 6Now we are going to simulate a very simple model of the solar system in which we ignorethe interactions among the planets and we assume the planets are just rotating oncircumferences around the sun.1. Create a class Planet that has the data members of name (type string), mass andcoordinates on a planet(type double) in km. Create this in its own separate files (.ccand .h) and define member setter and getter functions for each of the data members.a. In your main program, read the file Planets_data.txt line by line andinstantiate a new object of your class for each planet. Test your setter andgetter functions to ensure they work as expected.b. Store all your planets in a vector and try to add elements to the vector whileyou read the file.c. To check that the setter/getter functions work properly iterate on the vectorand print the information you stored on each planet2. Create a class SolarPlanet (.cc and .h) that inherits from the previous one all thefunctions, constructors and members but contains additional members: time, G(constant), mass of the sun, radius from the sun, angular_speed.a. Write the constructors and all the functions of this class making sure you useas much as possible of the class previously defined.3. Add a new function to the class, Evolve(double dt), which will change the coordinatesof your planets using the interval of time dt. To calculate the new coordinates justconsider that the trajectory of the planets depends only on the distance from the sun,the sun mass (1.9890e+30) and G(6.673e-20).4. Now you can evolve all your planets in main. For each planet evaluate the new x andy coordinates of the planet after a fixed interval of time dt till a certain time total_t,these two quantities need to be provided from the user as a command line arguments5. The output should be a new file for each Planet (named after the planet) thatcontains a line for each step in the evolution detailing the time from the beginningand the x and y coordinates of the Planet. Check that your program works inproducing circular orbits for the planets (if you save the file as .csv you can useexcel)6. Use your program to find the orbit times of all the planets and print the result on theterminal for each planet.

Reviews

There are no reviews yet.

Only logged in customers who have purchased this product may leave a review.

Shopping Cart
[Solved] CPP Assignment 4
30 $