The solution below reflects the result of all four parts
#include <iostream> #include <string> using namespace std; /* Function to remove planet from list @param planet_name planet to remove @param planets list of planets @param weights weight ratios for planets @param array_size @return new array size */ int remove_planet(string planet_name, string planets[], double weights[], int array_size) { // loop over each element of the array for (int i = 0; i < array_size; i++) { // looking for the requested planet name to remove if (planets[i] == planet_name) { // remove this element planets[i] = planets[array_size - 1]; weights[i] = weights[array_size - 1]; array_size--; } } // return the new size return array_size; } int main() { // Goal: print a list of planets starting with Earth and then Mercury - Pluto // These are not constants because we're going to modify them during the program string planets[] = { "Earth", "Mercury", "Venus", "Mars", "Jupiter", "Saturn", "Uranus", "Neptune", "Pluto", "Sun", "Moon"}; double weight_ratios[] = { 1.0, .38, .91, .38, 2.34, 1.06, .92, 1.19, .06, 27.072, .166 }; int array_size = 11; // prompt user if pluto is planet cout << "Is Pluto a planet (Y/N)? "; string input; cin >> input; // if it is not, remove it from the list if (input == "N") { // We need to update the size of the array because the function can't modify it int new_array_size = remove_planet("Pluto", planets, weight_ratios, array_size); array_size = new_array_size; } // prompt user for weight cout << "Weight: "; double user_weight; cin >> user_weight; cout << "PLANET\tWEIGHT" << endl; for (int i = 0; i < array_size; i++) { // Calculate and print out the weight for the ith planet double weight_on_planet_i = user_weight * weight_ratios[i]; cout << planets[i] << "\t" << weight_on_planet_i << endl; } cout << endl; system("pause"); return 0; }