/**** * * Implementation of planet.h. See that file for function descriptions. * */ #include "planet.h" #include #include Planet read_planet() { Planet p; printf( "Input planet name, diameter, number of moons, orbit time, and rotation time:\n"); scanf("%s%lf%d%lf%lf", p.name, &p.diameter, &p.moons, &p.orbit_time, &p.rotation_time); return p; } void print_planet(Planet p) { if (!is_empty(p)) { printf( "Planet name: %s\nDiameter: %.3f\nNumber of moons: %d\n\ Orbit time: %.3f\nRotation time: %.3f\n", p.name, p.diameter, p.moons, p.orbit_time, p.rotation_time); } else { printf("Empty Planet\n"); } } void change_name(Planet p, char* name) { strcpy(p.name, name); } void change_diameter(Planet* p, double diameter) { (*p).diameter = diameter; } void change_moons(Planet* p, int moons) { (*p).moons = moons; } void change_orbit_time(Planet* p, double orbit_time) { (*p).orbit_time = orbit_time; } void change_rotation_time(Planet* p, double rotation_time) { (*p).rotation_time = rotation_time; } int is_empty(Planet p) { return strcmp(p.name, "") == 0 && p.diameter == 0 && p.moons == 0 && p.orbit_time == 0 && p.rotation_time == 0; }