Question: Specifications Write a C + + program that will aid a chemistry student with the periodic table of elements. The text file named periodic.txt includes

Specifications
Write a C++ program that will aid a chemistry student with the periodic table of elements.
The text file named periodic.txt includes the basic information for each chemical element including the
code (1 or 2 characters), the name, the chemical number, and the chemical weight. Design a record
structure to store information for one element. Your program should then input information in the
entire file to an array of "element" record structures.
Your program should be driven by a simple menu. Allow the user to search the periodic table using
either the element code or the atomic number of the element. When you match the given user request,
provide all of the information on the element including the name, code, atomic number, and atomic
weight.
Include functions as detailed below. Consider the main tasks that are being performed and the data
"flowing" between actions. Be sure to include error checking to return an error message to the user if
either the atomic number or element code is not found in the data set. Finally, a variety of string
operations are required for this program.
LoadArray Primary responsibility: Loads periodic table array with records.
HOW: Pass the address of your structures array to the function. Use a loop to read in
the data records from the data file for each atom.
DisplayMenu Primary responsibility: Displays the program menu.
HOW: Display a menu that allows the user to search the periodic table using either the
element code or the atomic number. Return the menu selection to the calling
function.
CodeSearch Primary responsibility: Searches the structure array by element symbol(code).
How: Pass the address of your structures array and the symbol for the desired
element. Set up a loop to process the array, searching for the symbol. If found, return
the array index where the element was found. If not found, return -1.
NumberSearch Primary responsibility: Searches the structure array by atomic number (element
number).
HOW: Pass the address of your structures array and the atomic number for the desired
element. Set up a loop to process the array, searching for the atomic number. If
found, return the array index where the element was found. If not found, return -1.
In addition to the above functions, you should display the result of the search (e.g. whether the element
was found or not) and the associated information.
this as the base
#include
#include
#include
using namespace std;
//Structures
struct Element
{
string symbol;
string name;
int chemNum;
double chemWeight;
};
//Prototypes
void loadArray(Element []);
char displayMenu();
int codeSearch(Element[], string);
int numberSearch(Element[], int);
//Constants
const int SIZE =103;
int main()
{
//declare the structures array and any other needed variables
Element elements[SIZE];
int atomicNumber, codePos, numberPos;
string elementSymbol;
char contChoice, menuChoice;
//Output a header to the user.
cout<<"Welcome to the Periodic Table Search Program!"<> elmts[index].symbol;
inFile >> elmts[index].name;
inFile >> elmts[index].chemNum;
inFile >> elmts[index].chemWeight;
}
inFile.close();
}
//Purpose: T

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 Accounting Questions!