Question: Write a program using C++ to solve the following.: A program is needed to store the periodic table that is always growing (use a std:

 Write a program using C++ to solve the following.: A program

Write a program using C++ to solve the following.: A program is needed to store the periodic table that is always growing (use a std: vector). The following data needs to be stored for each element Atomic number (int) Element Name (string) Symbol (string) Atomic Mass (float) A struct would work perfect for this. However, for this to be even more useful, your class (make sure you use a h file as well the cpp file) should have a member function (private), which is called by the constructor to populate the first four elements with the correct data (element data is available online). There also needs to be the following public functions that will be called by your main: A function to print out entire table in order(formatted nicely) A function to add an element (prompts for the data in your main) Finally, since the function to print out needs to have the data in order (by atomic number) need to sort you vector. See http://www.cplusplus.com/reference/algorithm/sort/ for an example on using the sort command. Specifically from the link above: // using object as comp std: :sort (myvector.begin), myvector.end (), myobject) Where myobject is your own compare function; Note the myobject at the end of the struct definition (before the :) is a shorthand way to declare an object of this type (at the link above) Note: You will have to implement your own compare function based on the atomic number (make sure you pass your objects (struct) into the "bool operator()" by reference Zip up your entire netbeans project and submit. Also, include sample output from a run

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!