Question: Image 1: Image 2: The code given below is all that follows for the first image. Please design the code instructed for the second image

Image 1:

Image 1: Image 2: The code given below is all that follows

Image 2:

for the first image. Please design the code instructed for the second

The code given below is all that follows for the first image. Please design the code instructed for the second image by modifying the given code. Write the code in C++ and please do not include any goto functions. Provide a picture of the code being executed at the end. Thank you.

//planets.C

#include

using namespace std;

class planet{ private: string name; float mass; float radius; public: //constructer to intialize default values planet(){ name=""; mass=0; radius=0; } // function to set Name //this os used for current object reference void setName(string x){ this->name=x; } // function to set Radius void setRadius( float x){ this->radius=x; } // function to set Mass void setMass( float x){ this->mass=x; } //function to get Name string getName(){ return name; } // funtion to get Radius float getRadius(){ return radius; } //Function to get Mass float getMass(){ return mass; }

// function to claculate parameters void calculateParameters(){ float pi = 3.14159; float surfacearea,density,accduetogravity; // surface area = 4*pi* radius *radius surfacearea=4 * pi * radius * radius; float vol; vol = (float(4) / float(3)) * pi * radius *radius * radius; // density = mass/volume density=mass/vol; //acleration due to gravity g= G*mass/(raduius*radius) //G is constant value is 6.67*10 ^-11 accduetogravity=(mass)*6.6*0.000000001/radius*radius; cout

// function to take input planet* input(planet *p){ string name; float inp; cout>name; p->setName(name); cout>inp; p->setMass(inp); cout>inp; p->setRadius(inp); return p; }

// function to dislpay values void display(planet *p){ coutgetName()getRadius()getMass()calculateParameters(); cout

int main() { // create object of new planet planet *p=new planet();

p=input(p); display(p); return 0; }

Planet Create a planet class. The members of the class will be the planet name, radius and mass which must be private. The member functions must include a get and set function for each member, constructor, and functions to calculate the surface area, density and acceleration due to gravity at the planet's surface. You may optionally include an input and display function Write a program that uses your class to generate some test results Write a program that will keep track of planets. Your program should make use of your planet class from the previous assignment and display a menu similar to this: 1. Add Planet 2. Delete Planet 3. Find Planet 4. List Planets 5. Sort Planets 6. Quit Adding a planet will prompt the user for name, mass and diameter and add the planet to the vector. When deleting a planet, your program will prompt the user for the planets name, find the planet by name in the vector, then remove it. When finding a planet, your program will prompt the user for the planets name, find the planet by name and display the name, mass, diameter, surface area, density and acceleration due to gravity at the planet's surface. When listing the planets, show the same information as above for all planets in the list. Sorting the planets will be done via alphabetical order. (This does not need to be case insensitive). Note that if you use an insertion sort when adding planets, this option is not needed

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!