Find an element in the periodic table.
In 1869 Russian chemist Dimitri Mendeleev started the development of the periodic table, arranging chemical elements by atomic mass. He predicted the discovery of other elements, and left spaces open in his periodic table for them.
Write a program that allows the user to enter the symbol or name of an element. The program outputs the name of the element, the atomic weight and the group of elements it belongs to using the data in the table below.
Use this boilerplate code as a starting point:
Remember to add a comment before a subprogram or selection statement to explain its purpose.
Symbol | Element | Atomic weight | Group |
---|---|---|---|
Li | Lithium | 6.94 | Alkali metals |
Na | Sodium | 22.99 | Alkali metals |
K | Potassium | 39.098 | Alkali metals |
F | Fluorine | 18.998 | Halogens |
Cl | Chlorine | 35.45 | Halogens |
Br | Bromine | 79.904 | Halogens |
Enter the symbol or name of an element: K
Element: Potassium
Atomic weight: 39.098
Group: Alkali metals
Enter the symbol or name of an element: Clorine
Element: Chlorine
Atomic weight: 35.45
Group: Halogens
Use these resources as a reference to help you meet the success criteria.
Run the unit tests below to check that your program has met the success criteria.
Enter the symbol or name of an element: K
Element: Potassium
Atomic weight: 39.098
Group: Alkali metals
Enter the symbol or name of an element: Clorine
Element: Chlorine
Atomic weight: 35.45
Group: Halogens
Check that you have: