Define a C++ struct named Element with the following members: • symbol : string, The symbol for the chemical element • name : string, The name of the chemical element • atomicNumber : int, The atomic...

1 answer below »
Define a C++ struct named Element with the following members: • symbol : string, The symbol for the chemical element • name : string, The name of the chemical element • atomicNumber : int, The atomic number of the element • atomicWeight : double, The atomic weight of the element • active : bool, Flag variable controlling its visibility Define an array of Element structures named elements that can hold up to 50 instances of the Element structure. Write a menu-driven program that prompts your user with the following six choices: Select an option number from the following menu: Option Action ------ ----------------------------------------- 1 Define a chemical element. 2 Search for an element. 3 Change the visibility of an element. 4 Define elements from a text file. 5 Display the elements sorted by symbol. 6 Quit. Enter your choice: Option 1 will prompt the user for a chemical symbol, the corresponding element name, atomic number, and atomic weight. It will then use that information to define the next available entry in the array of elements. Option 2 will prompt the user for a chemical symbol such as “C” for Carbon. If that chemical symbol exists in the array of elements, the program will display the symbol, name, atomic number, and atomic weight of that element. If the chemical symbol is not in the array of elements, display an informative message instead. Option 3 will prompt the user for a chemical symbol such as “B” for Boron. If that chemical symbol exists in the array of elements, the program will assign the value false to the active member for that array entry. If the chemical symbol does not exist in the array of elements, an informative message will be displayed instead. Copyright 2021, Dallas College. All Rights reserved. Page 2 of 3 Note: The structure member named active is initialized to true when an entry is created. Once the member named active is set to the value false in Option 3, it is invisible to all other program options. Your program does not have to delete such an entry. It just has to ignore it by not displaying it. Option 4 prompts the user to identify a file containing the descriptions of several elements This text file contains one record per line containing the chemical symbol, element name, atomic number, and atomic weight of several elements. The fields are separated from each other by a blank space. A sample file named “elements.txt” is available in Blackboard to assist you in testing this portion of your program. Your program will read and process all the records in the file, adding an entry to the array of elements for each record in the file. Option 5 will display a formatted list of the contents of the elements array sorted in ascending order by chemical symbol. This is an example of the desired output from selecting this option: Atomic Atomic Symbol Name Number Weight ------ ------------ ------ ------- Al Aluminum 13 26.982 Ar Argon 18 39.880 B Boron 5 10.810 Be Beryllium 4 9.012 C Carbon 6 12.011 Ca Calcium 20 40.078 Cl Chlorine 17 35.450 Option 6 will terminate the program. Your program will repeatedly prompt the user with the menu choices until the user enters option 6 to quit. Use input validation to guard against your user from entering menu choices outside the range from 1 to 6. Use formatting to display the information contained in the array of Element structures. Display atomic weights with three digits after the decimal point. To receive full credit for this programming assignment, your submission must: • Use a correctly formed file name. • Submit a program that executes correctly. • Interact effectively with the user in your prompts and messages. Copyright 2021, Dallas College. All Rights reserved. Page 3 of 3 Grading Guideline: • Create a comment containing the student’s full name. (5 points) • Document the program with other meaningful comments. (5 points) • Repeatedly display the required choices. (10 points) • Use input validation to verify the user’s option choice. (5 points) • Process Option 1 correctly, adding an element. (15 points) • Process Option 2 correctly, identifying and displaying an entry. (15 points) • Process Option 3 correctly, making an entry “invisible”. (10 points) • Process Option 4 correctly, adding elements from a file. (15 points) • Process Option 5 correctly, displaying the contents sorted in ascending order by chemical symbol. (15 points) • Use prompts and messages that are easy to understand. (5 points)
Answered 2 days AfterDec 03, 2021

Answer To: Define a C++ struct named Element with the following members: • symbol : string, The symbol for the...

Vaibhav answered on Dec 05 2021
121 Votes
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here