The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 103 Weeks Ago, 2 Days Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
may someone help me in my Assignment in Java II? The assignment's document is attached.
Â
Extra Credit: StacksObjectives:The focus of this assignment is understanding of the Stack structure and implementing one of its uses. Usethe Stack class that is deFned in the java API, in the java.util package.Program Background:Amoleculeis a grouping of two or more atoms. A molecule can be written as a sequence of the symbolsof its atoms. ±or example, H denotes an atom of hydrogen, C denotes an atom of carbon, and O denotes anatom of oxygen.Formic Acidis deFned by the sequence HCOOH, which is a hydrogen, carbon, oxygen,oxygen, hydrogen. If a digit is placed after a symbol it means there are that many of those atoms in themolecule, such aswater, H2O is two hydrogen atoms and an oxygen. Digits can also be placed aftergroupings such as (CH)3 which is three carbon/hydrogen groupings, (CH)(CH)(CH). The weight of amolecule is simply the weight of all the atoms in it. Given the weight of hydrogen is 1, carbon is 12, andoxygen is 16, ±ormic Acid has a weight of 46, Water has a weight of 18, and (CH)3 has a weight of 39. Morecomplex molecules sequences can be created by nesting groupings such as H((OH)2C3H)2, which has aweight of 143.Parenthesis and other types of braces must follow rules in order for an expression to be valid. Stacks areoften used for processing of parenthesis in text, such as compilers making sure braces match up correctly.A Stack can also be used to evaluate parenthesized expressions like we have here.Every opening and closing parenthesis must have a matching of the other. It is also important to note thatin valid text the matching opening parenthesis to a closing one islast oneencountered. This is whatmakes the Stack the perfect structure for such problems. Open parenthesis signify the beginning of agrouping, nested groupings can be added to the stack. Once a closing parenthesis is reached it closes thegroup at the top of the stack, which can then be evaluated.Program Description:The program will accept a number of molecule sequences and report their weights.The following classes are required:InvalidAtomExceptionInvalidSequenceExceptionMoleculeMoleculeDriverUML DIAGRAM FOR AND DISCUSSION FOR InvalidAtomExceptionInvalidAtomException extends RuntimeException<<constructor>>InvalidAtomException(atom : char)Methods:InvalidAtomException(atom : char)– Class constructor. Calls upon super class constructor with the String,“Invalid atom value: “, followed by the character that is passed.
Attachments: