Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

COSC-1436, Element Array Project C++ struct named Element with the following members: symbol : string, The symbol for the chemical element name : string, The

COSC-1436, Element Array Project 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

Define an array of Element structures named elements that can hold up to 50 instances of the Element structure.

Menu-driven program that prompts your user with the following six choices: Select an option number from the following menu:

Option Action

1 Load elements from a text file. 2 Display the collection sorted by symbol. 3 Add a chemical element to the collection. 4 Delete an element from the collection. 5 Search for an element in the collection. 6 Quit.

Enter your choice:

Option 1 prompts the user to identify a file containing the descriptions of several chemical 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 2 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 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

Option 3 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 4 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 delete that entry from the array. If the chemical symbol does not exist in the array of elements, an informative message will be displayed instead.

Option 5 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 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.

Include 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 elements from a file. (15 points) Process Option 2 correctly, displaying the contents sorted in ascending order by chemical symbol. (15 points) Process Option 3 correctly, adding an element. (15 points) Process Option 4 correctly, deleting an entry. (10 points) Process Option 5 correctly, identifying and displaying an entry. (15 points) Use prompts and messages that are easy to understand. (5 points) meet all this requirement.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Mobile Communications

Authors: Jochen Schiller

2nd edition

978-0321123817, 321123816, 978-8131724262

More Books

Students also viewed these Programming questions

Question

Which artificial intelligence should be legislated or regulated?

Answered: 1 week ago