Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program to process periodic table information from a file. Each element will have an atomic number, a name, an abbreviation, and a

Write a C++ program to process periodic table information from a file. Each element will have an atomic number, a name, an abbreviation, and a mass. Your program must include: 1. An Element structure to be defined in a header file: Element.h 2. A function read_table that will return the number of elements read from the file and via a reference parameter, a pointer to an array of pointers to the elements read. The data file is periodictable.dat. This function must read in the data by constructing a linked list and convert the linked list into an array of pointers. The prototype for this function is to be included in the Element.h file. The function will return 0 on any error condition. 3. A main program that will call read_table to read in the table, sort the table using the element name and print out the table using the required output format. You can use qsort in cstdlib or write your own sort function. 4. Dynamic memory must be allocated and deallocated properly.

Here is periodictable.dat:

image text in transcribed

File Edit earch View Encoding Language Settings Tools Macro Run Plugins Window ? perodctable dat * 1 1 H 1.00794 Hydrogen 65 65 Tb 158.92535 Terbium 2 2 He 4.002602 Helium Dysprosium 67 67 Ho 164.93032 Holmium 68 68 Er 167.259 Erbium 69 69 Tm 168.93421 Thulium 70 70 Yb 173.054 Ytterbium 71 71 Lu 174.9668 Lutetium 72 72 Hf 178.49 Hafnium 73 73 Ta 180.94788 Tantalum 74 74 W 183.84 Tungsten 75 75 Re 186.207 Rhenium 76 76 Os 190.23 Osmiunm 77 77 Ir 192.217 Iridium 78 78 Pt 195.084 Platinum 79 79 Au 196.966569 Gold 80 80 Hg 200.59 Mercury 81 81 TI 204.3833 Thallium 82 82 Pb 207.2 Lead 83 83 Bi 208.9804 Bismuth 4 4 Be 9.012182 Beryllium 5 5 B 10.811 Boron 6 6 12.0107 Carbon 7 7 N 14.0067 Nitrogen 8 8 o 15.9994 Oxygen 9 9 F 18.9984032 Fluorine 10 10 Ne 20.1797 Neon 11 11 Na 22.98976928 Sodium 12 12 Mg 24.305 Magnesium 13 13 Al 26.9815386 Aluminum 14 14 Si 28.0855 Silicon 15 15 P 30.973762 Phosphorus 16 16 S 32.065 Sulfur 17 17 cl 35.453 Chlorine 18 18 Ar 39.948 Argon 19 19 K 39.0983 Potassium 20 20 40.078 calcium 21 21 Sc 44.955912 Scandium 22 22T 47.867 Titanium 23 v 50.9415 Vanadium 24 24 Cr 51.9961 Chromium 25 25 Mn 54.938045 Manganese 85 85 At 210 Astatine 86 86 Rn 222 Radon 87 87 Fr 223 Francium 88 88 Ra 226 Radium 55.845 Iron 27 27 Co 58.933195 Cobalt 28 28 N 58.6934 Nickel 29 29 Cu 63.546 Copper 227 31 31 Ga 69.723 Gallium 32 32 Ge 72.64 Germanium 33 33 As 74.9216 Arsenic 90 90 Th 232.03806Thorium 91 91 Pa 231.03588 Protactinium 92 92 U 238.02891 Uranium 93 93 Np 237 Neptuni 94 94 Pu 244 Plutonium 95 95 Am 243 Americium 96 96 Cm 247 Curium 35 35 Br 79.904 Bromine 36 36 Kr 83.798 Krypton 37 37 Rb 85.4678 Rubidium 38 38 Sr 87.62 Strontium 39 39 Y 88.90585 Yttrium 40 40 2r 91.224 2irconium 41 41 Nb 92.90638 Niobium 2 42 Mo 95.96 Molybden 43 43 Tc 98 Technetium 44 44 Ru 101.07 Ruthenium 45 45 Rh 102.9055 Rhodium 46 46 pd 106.42 Palladium 47 47 Ag 107.8682 silver 48 48 cd 112.411 Cadmium 49 49 In 114.818 Indium um 7 97 Bk 247 Berkeli 98 98 Cf 251 Californium 257 uim 101 101 Md 258 Mendelevium 102 102 No 259 Nobelium 103 103 Lr 262 Lawrencium 104 104 Rf 267 Rutherfordiunm 105 105 Db 268 Dubnium 106 106 Sg 271 Seaborgium 107 107 Bh 272 Bohrium 52 52 Te 127.6 Tellurium 53 53 I 126.90447 Iodine 5 assium 109 109 Mt 276 Meitnerium 110 110 Ds 281Darmstadtium 55 55 Cs 132.9054519 Cesiunm 56 56 Ba 137.327 Barium 57 57 La 138.90547 Lanthanum 112 112 Cn 285 Copernicium 113 113 Uut 284 Ununtrium 114 114 Uuq 289 Ununquadium 115 115 Uup 288 Ununpentium 116 116 Uuh 293 Ununhexium 117 117 Uus 294 Ununseptium 118 118 Uuo 294 Ununoctium Ce 140.116 Cerium 59 59 Pr 140.90765 Praseodymium um 61 61 Dm 145 Promethium 62 62 Sm 150.36 Samarium 63 63 Eu 151.964 Europium 64 64 Gd 157.25 Gadolinium 65 65 Tb 158.92535 Terbium 66 66 Dy 162.5 Dysprosium 67 67 Ho 164.93032 Holmium File Edit earch View Encoding Language Settings Tools Macro Run Plugins Window ? perodctable dat * 1 1 H 1.00794 Hydrogen 65 65 Tb 158.92535 Terbium 2 2 He 4.002602 Helium Dysprosium 67 67 Ho 164.93032 Holmium 68 68 Er 167.259 Erbium 69 69 Tm 168.93421 Thulium 70 70 Yb 173.054 Ytterbium 71 71 Lu 174.9668 Lutetium 72 72 Hf 178.49 Hafnium 73 73 Ta 180.94788 Tantalum 74 74 W 183.84 Tungsten 75 75 Re 186.207 Rhenium 76 76 Os 190.23 Osmiunm 77 77 Ir 192.217 Iridium 78 78 Pt 195.084 Platinum 79 79 Au 196.966569 Gold 80 80 Hg 200.59 Mercury 81 81 TI 204.3833 Thallium 82 82 Pb 207.2 Lead 83 83 Bi 208.9804 Bismuth 4 4 Be 9.012182 Beryllium 5 5 B 10.811 Boron 6 6 12.0107 Carbon 7 7 N 14.0067 Nitrogen 8 8 o 15.9994 Oxygen 9 9 F 18.9984032 Fluorine 10 10 Ne 20.1797 Neon 11 11 Na 22.98976928 Sodium 12 12 Mg 24.305 Magnesium 13 13 Al 26.9815386 Aluminum 14 14 Si 28.0855 Silicon 15 15 P 30.973762 Phosphorus 16 16 S 32.065 Sulfur 17 17 cl 35.453 Chlorine 18 18 Ar 39.948 Argon 19 19 K 39.0983 Potassium 20 20 40.078 calcium 21 21 Sc 44.955912 Scandium 22 22T 47.867 Titanium 23 v 50.9415 Vanadium 24 24 Cr 51.9961 Chromium 25 25 Mn 54.938045 Manganese 85 85 At 210 Astatine 86 86 Rn 222 Radon 87 87 Fr 223 Francium 88 88 Ra 226 Radium 55.845 Iron 27 27 Co 58.933195 Cobalt 28 28 N 58.6934 Nickel 29 29 Cu 63.546 Copper 227 31 31 Ga 69.723 Gallium 32 32 Ge 72.64 Germanium 33 33 As 74.9216 Arsenic 90 90 Th 232.03806Thorium 91 91 Pa 231.03588 Protactinium 92 92 U 238.02891 Uranium 93 93 Np 237 Neptuni 94 94 Pu 244 Plutonium 95 95 Am 243 Americium 96 96 Cm 247 Curium 35 35 Br 79.904 Bromine 36 36 Kr 83.798 Krypton 37 37 Rb 85.4678 Rubidium 38 38 Sr 87.62 Strontium 39 39 Y 88.90585 Yttrium 40 40 2r 91.224 2irconium 41 41 Nb 92.90638 Niobium 2 42 Mo 95.96 Molybden 43 43 Tc 98 Technetium 44 44 Ru 101.07 Ruthenium 45 45 Rh 102.9055 Rhodium 46 46 pd 106.42 Palladium 47 47 Ag 107.8682 silver 48 48 cd 112.411 Cadmium 49 49 In 114.818 Indium um 7 97 Bk 247 Berkeli 98 98 Cf 251 Californium 257 uim 101 101 Md 258 Mendelevium 102 102 No 259 Nobelium 103 103 Lr 262 Lawrencium 104 104 Rf 267 Rutherfordiunm 105 105 Db 268 Dubnium 106 106 Sg 271 Seaborgium 107 107 Bh 272 Bohrium 52 52 Te 127.6 Tellurium 53 53 I 126.90447 Iodine 5 assium 109 109 Mt 276 Meitnerium 110 110 Ds 281Darmstadtium 55 55 Cs 132.9054519 Cesiunm 56 56 Ba 137.327 Barium 57 57 La 138.90547 Lanthanum 112 112 Cn 285 Copernicium 113 113 Uut 284 Ununtrium 114 114 Uuq 289 Ununquadium 115 115 Uup 288 Ununpentium 116 116 Uuh 293 Ununhexium 117 117 Uus 294 Ununseptium 118 118 Uuo 294 Ununoctium Ce 140.116 Cerium 59 59 Pr 140.90765 Praseodymium um 61 61 Dm 145 Promethium 62 62 Sm 150.36 Samarium 63 63 Eu 151.964 Europium 64 64 Gd 157.25 Gadolinium 65 65 Tb 158.92535 Terbium 66 66 Dy 162.5 Dysprosium 67 67 Ho 164.93032 Holmium

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

Step: 3

blur-text-image

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

More Books

Students also viewed these Databases questions

Question

Develop clear policy statements.

Answered: 1 week ago

Question

Explain all drawbacks of application procedure.

Answered: 1 week ago

Question

Explain the testing process of accounting 2?

Answered: 1 week ago