number as an argument for the number of Planets that will be in your SolarSystem. So if you call addPlanets with 5 as an argument, there will be 5 Planets to add to the SolarSystem. You can start by resizing the vector to this argument value. Then, you can ask for information about each Planet object (name, mass, diameter). So, you’ll need a loop in this function, which will contain the statements: cout << "Name, mass, diameter: "; cin >> pl

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question
Create a new project named lab10. You will be implementing two classes: A SolarSystem class, and a Planet class. The SolarSystem contains Planet objects stored in a vector. A UML diagram for the Solar System and Planet classes The first part you should implement is the Planet class. Don't add the SolarSystem files to the project at the beginning, just work on the Planet class. Test the different overloaded operators as we did during lecture for your Planet class, and then move on to the SolarSystem class. The SolarSystem default constructor should resize the vector to zero. The default constructor values for Planet can be whatever you’d like, but make the mass a very small number, so later on when you're looking for the largest planet, it doesn't use the default Planet value. The addPlanets() method will take a number as an argument for the number of Planets that will be in your SolarSystem. So if you call addPlanets with 5 as an argument, there will be 5 Planets to add to the SolarSystem. You can start by resizing the vector to this argument value. Then, you can ask for information about each Planet object (name, mass, diameter). So, you’ll need a loop in this function, which will contain the statements: cout << "Name, mass, diameter: "; cin >> planets[i]; // if you used an index-based for loop The planetWithLargestMass() function will have to iterate through each element in the vector, and determine which is largest. Don’t forget, you’ve already overloaded the >= operator, so this should similar to finding the largest value is an array/vector of integers. In the sample run, make use of one of the overloaded operators for Planet. You come up with a use for the other overloaded operator. Sample run: How many planets are in your solar system? 3 Okay, let’s get information for 3 planets. Name, mass, diameter: Miller 6000 9900 Name, mass, diameter: Mann 6500 8500 Name, mass, diameter: Edmunds 5500 7000 Your Solar System contains 3 planets. The Miller planet - Mass: 6000 yottagrams, Diameter: 9900 miles. The Mann planet - Mass: 6500 yottagrams, Diameter: 8500 miles. The Edmunds planet - Mass: 5500 yottagrams, Diameter: 7000 miles. Which planet has the largest mass? The Mann planet - Mass: 6500 yottagrams, Diameter: 8500 miles. This is a main function in the driver file: #include "SolarSystem.h" using namespace std; int main() { //declarations SolarSystem the_system; int num_planets; //input and output cout << "How many planets are in your solar system? "; cin >> num_planets; //add planets the_system.addPlanets(num_planets); //print the solar system cout << the_system << endl; //print the planet with largest mass cout << "Which planet has the largest mass?\n"; the_system.planetWithLargestMass(); return 0; }
Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education