Question: Write a program that reads data about the atomic elements and then displays the information when the user enters the atomic number of the element.

Write a program that reads data about the atomic elements and then displays the information when the user enters the atomic number of the element.
The file elements.txt contains the following information on each line for each of the 118 elements:
 Write a program that reads data about the atomic elements and elements.txt: 89 Actinium 227
13 Aluminium 26.9815385
95 Americium 243
51 Antimony 121.76
18 Argon 39.948
33 Arsenic 74.921595
85 Astatine 210
56 Barium 137.327
97 Berkelium 247
4 Beryllium 9.0121831
83 Bismuth 208.9804
107 Bohrium 270
5 Boron 10.81
35 Bromine 79.904
48 Cadmium 112.414
55 Caesium 132.905452
20 Calcium 40.078
98 Californium 251
6 Carbon 12.011
58 Cerium 140.116
17 Chlorine 35.45
24 Chromium 51.9961
27 Cobalt 58.933194
112 Copernicium 285
29 Copper 63.546
96 Curium 247
110 Darmstadtium 281
105 Dubnium 268
66 Dysprosium 162.5
99 Einsteinium 252
68 Erbium 167.259
63 Europium 151.964
100 Fermium 257
114 Flerovium 289
9 Fluorine 18.99840316
87 Francium 223
64 Gadolinium 157.25
31 Gallium 69.723
32 Germanium 72.63
79 Gold 196.966569
72 Hafnium 178.49
108 Hassium 277
2 Helium 4.002602
67 Holmium 164.93033
1 Hydrogen 1.008
49 Indium 114.818
53 Iodine 126.90447
77 Iridium 192.217
26 Iron 55.845
36 Krypton 83.798
57 Lanthanum 138.90547
103 Lawrencium 266
82 Lead 207.2
3 Lithium 6.94
116 Livermorium 293
71 Lutetium 174.9668
12 Magnesium 24.305
25 Manganese 54.938044
109 Meitnerium 278
101 Mendelevium 258
80 Mercury 200.592
42 Molybdenum 95.95
115 Moscovium 290
60 Neodymium 144.242
10 Neon 20.1797
93 Neptunium 237
28 Nickel 58.6934
113 Nihonium 286
41 Niobium 92.90637
7 Nitrogen 14.007
102 Nobelium 259
118 Oganesson 294
76 Osmium 190.23
8 Oxygen 15.999
46 Palladium 106.42
15 Phosphorus 30.973762
78 Platinum 195.084
94 Plutonium 244
84 Polonium 209
19 Potassium 39.0983
59 Praseodymium 140.90766
61 Promethium 145
91 Protactinium 231.03588
88 Radium 226
86 Radon 222
75 Rhenium 186.207
45 Rhodium 102.9055
111 Roentgenium 282
37 Rubidium 85.4678
44 Ruthenium 101.07
104 Rutherfordium 267
62 Samarium 150.36
21 Scandium 44.955908
106 Seaborgium 269
34 Selenium 78.971
14 Silicon 28.085
47 Silver 107.8682
11 Sodium 22.98976928
38 Strontium 87.62
16 Sulfur 32.06
73 Tantalum 180.94788
43 Technetium 98
52 Tellurium 127.6
117 Tennessine 294
65 Terbium 158.92535
81 Thallium 204.38
90 Thorium 232.0377
69 Thulium 168.93422
50 Tin 118.71
22 Titanium 47.867
74 Tungsten 183.84
92 Uranium 238.02891
23 Vanadium 50.9415
54 Xenon 131.293
70 Ytterbium 173.045
39 Yttrium 88.90584
30 Zinc 65.38
40 Zirconium 91.224

Write a program that reads data about the atomic elements and then displays the information when the user enters the atomic number of the element. The file elements.txt contains the following information on each line for each of the 118 elements: Atomic number Name Atomic weight All elements are numbered from 1 to 1 18 There are no missing numbers. The name of the element (i.e. Oxygen). The weight of an atom of this element. This number has a decimal point. arrays start their numbering There are 118 elements in the file numbered 1 to 118. Remember that at zero. The elements in the file are not in sequential order. Your program will want to read the file and make a simple Element object for each of the elements. The objects should be stored in an array using the atom ic number as the index of the array The Element class should have two class instance variables to hold the name and atomic weight You will need to a constructor to initialize these to values to constructor parameters. After reading the data from the file and creating the objects in the array, the program should ask the user for an atomic number. Using the number as an index into the array, the program should display the name and atomic weight of the element. Program outline while more data in the file read number, name and weight from the file create Element object with name and weight put object in the array indexed by the atomic number while requestedNu>0 read requestedNum from keyboard if requestedNum>0 atom Element object at index requestedNum display name and weight of atom Sample output Enter atomic number of element >8 Oxygen with atomic weight 15.999 Enter atomic number of element >82 Lead with atomic weight 207.2 Enter atomic number of element >116 Livermorium with atomic weight 293.0 Enter atomic number of element >0

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