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

Question: Define and implement a class planet to hold all their details. (x,y,z

ID: 3630837 • Letter: Q

Question

Question:
Define and implement a class planet to hold all their details. (x,y,z coordinates are to be stored with float precision).

Define and implement a function, report_planet, that takes an argument identifying a
plant instance and reports its details to the screen.

Define and implement a function, get_details, that takes an argument identifying an
existing plant instance and prompts the user through messages on the screen to enter the planet’s id number and coordinates

My code:


#include <iostream.h>
class planet
{private:

float x;
float y;
float z;
int id;

public:
void get_details(int,int,int,int);
void report_planet(int);

};

void planet::get_details(int x,int y,int z,int id)
{cout<<"Enter coordinates for planet: ";
cout<<"Enter x: ";
cin>>planet.x;
cout<<"Enter y: ";
cin>>planet.y;
cout<<"Enter z: ";
cin>>planet.z;
cout<<"Enter id: ";
cin>>id;
}
void planet::report_planet(int id)
{
cout<<"Planet id: "<<id;
cout<<"Coordinates("<<planet.x<<", "<<planet.y<<", "<<planet.z<<") ";
};

int main()
{
planet a;
planet::get_details(a);
planet::report_planet(int id);


return 0;
}
Thank you very much !

Explanation / Answer

please rate - thanks

try this



#include <iostream.h>
class planet
{private:

float x;
float y;
float z;
int id;

public:
void get_details();
void report_planet();

};

void planet::get_details()
{cout<<"Enter coordinates for planet: ";
cout<<"Enter x: ";
cin>>x;
cout<<"Enter y: ";
cin>>y;
cout<<"Enter z: ";
cin>>z;
cout<<"Enter id: ";
cin>>id;
}
void planet::report_planet()
{
cout<<"Planet id: "<<id<<endl;
cout<<"Coordinates("<<x<<", "<<y<<", "<<z<<") ";
};

int main()
{
planet a;
a.get_details();
a.report_planet();

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote