Question: C++ Write a function, maxRadius , to find an index of a P lanet with the largest radius in the array. The function should Be

C++

Write a function, maxRadius, to find an index of a Planet with the largest radius in the array. The function should

  • Be named maxRadius

  • Take two arguments in the following order

    • An array of Planet objects

    • Integer, the size of the array (possibly partially filled, so this would be the number of actual Planet elements in the array)

  • Return the index (integer) of the Planet in the array with the largest radius.

  • If multiple Planets in the array share the largest radius, your function should return the index of the first Planet.

  • If the array of Planet objects is empty, your function should return -1

In the Answer Box, paste your Planet class, its implementation, and your maxRadius function. (Submit what you did for Problem 1, and add your maxRadius function.) Do not include your main() function from maxRadiusDriver.cpp that you used for testing your function.

here are the other 2 programs

C++ Write a function, maxRadius, to find an index of a Planet

#ifndef PLANET_H #define PLANET_H #include  using namespace std; class Planet { private: string planetName; double planetRadius; public: Planet(); Planet(string planetName, double planetRadius); string getPlanetName(); void setPlanetName(string planetName); double getPlanetRadius(); void setPlanetRadius(double planetRadius); double getVolume(); }; #endif 

with the largest radius in the array. The function should Be named

#include "Planet.h" Planet::Planet() {} Planet::Planet(string planetName, double planetRadius) : planetName(planetName), planetRadius(planetRadius) {} string Planet::getPlanetName() { return planetName; } void Planet::setPlanetName(string planetName) { Planet::planetName = planetName; } double Planet::getPlanetRadius() { return planetRadius; } void Planet::setPlanetRadius(double planetRadius) { Planet::planetRadius = planetRadius; } double Planet::getVolume() { return (4.0/3) * 3.14159 * planetRadius * planetRadius * planetRadius; } 

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!