Answered step by step
Verified Expert Solution
Question
1 Approved Answer
C++ program Problem A: A Basic Molecule Class (20 points) A molecule is an electrically neutral group of two or more atoms held together by
C++ program
Problem A: A Basic Molecule Class (20 points) A molecule is an electrically neutral group of two or more atoms held together by chemical bonds. Atoms are held together by bonds, mostly single bonds, but in some (rare) cases the bonding may include two double bonds and/or a triple bond. Many experiments involve the use of molecules, and a plethora of data can be created and analyzed by a system which can represent and encode their properties and workings Write a C++ program that creates, stores, and provides access to Molecule objects. Create a class named Molecule. This class maintains an array of elements (of max size 10), an array of counts of each element (of max size 10), the number of bonds (no more than the total number of elements plus 4), and a charge (which can be positive, negative, or neutral). You should build the appropriate mutators and accessors (you will not need for an accessor for each individual element count - but you will need a mutator to be able to set an individual count) The accessor method for elements should return a comma-separated list of the values as a string. You should also declare and define a method that returns the total count of elements, a method that prints the counts as a comma-separated list, and finally, declare and define a method that prints out all the values associated with a molecule object To test the Molecule class, write a main function which allows the user to enter elements (a maximum of 10); counts (a maximum of 10); a number of bonds, and a charge. The main function should then call the method to print the resulting Molecule Your program should include a continuation loop so you can test more than one molecular configuration. An example run of the program is as follows (user input is in bold font): Enter the element and its count (enter Q 0 to stop): H 2 Enter the element and its count (enter Q' 0 to stop): 0 1 Enter the element and its count (enter 'Q0 to stop): aQ 0 Enter the number of bonds: 1 Enter the charge (-1 for negative, O for neutral, 1 for positive): 0 H, O 3 Neutral Elements Counts otal count: Bonds Charge Would you like to continue (y)? Y Enter the element and its count (enter Q' 0 to stop): C 1 Enter the element and its count (enter Q 0 to stop): O 2 Enter the element and its count (enter Q' 0to stop): Q 0 Enter the number of bonds: 1 Enter the charge (-1 for negative, O for neutral, 1 for positive): 0Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started