The word "cat" can be spelled from the period table element symbols by using the sequence of elements carbon and astatine in that order. Since the symbol for carbon is "C" and the symbol for astatine is "At", which together makes [C][At]; thus, "cat" is an elemental phrase. To determine which elements can be used all combinations of 1 and 2 letter element symbols must be tested. Write a java program to determine if a lowercase word can be made with any combination of 1 or 2 letter element symbols from the periodic table. The list elements will come from a text file containing all the atomic elements and their symbols. The user will enter a lowercase word to check for from the keyboard. Assume the word is properly spelled but check for all lowercase letters. Output to the screen the list of chemical elements if it can be made from the element symbols following the format as seen below, if not output: "No element phrase possible." Output all possible solutions if applicable. Finally, ask the user if he/she would like to run the program again. Check case. Let the user input the file name from the keyboard. The program must use lists and recursion for full credit. Refer to the sample output below. Sample Run: Enter the file name: elements.txt This program read words and determines whether a word can be spelled using the symbols from the periodic table. Enter the word: bananas Matching bananas: Solution 1: [Ba][Na][N][As]: barium sodium nitrogen arsenic Solution 2: [Ba][Na][Na][S]: barium sodium sodium sulfur Run again (Y/N): Y Enter the word: champions Matching champions: Solution 1: [ C][H][Am][P][I][O][N][S]: carbon hydrogen americium phosphorus iodine oxygen nitrogen sulfur Run again (Y/N): y 84At6 C Enter the word: north Matching north: No element phrase possible. Run again (Y/N): n
The word "cat" can be spelled from the period table element symbols by using the sequence of elements carbon and astatine in that order. Since the symbol for carbon is "C" and the symbol for astatine is "At", which together makes [C][At]; thus, "cat" is an elemental phrase. To determine which elements can be used all combinations of 1 and 2 letter element symbols must be tested. Write a java program to determine if a lowercase word can be made with any combination of 1 or 2 letter element symbols from the periodic table. The list elements will come from a text file containing all the atomic elements and their symbols. The user will enter a lowercase word to check for from the keyboard. Assume the word is properly spelled but check for all lowercase letters. Output to the screen the list of chemical elements if it can be made from the element symbols following the format as seen below, if not output: "No element phrase possible." Output all possible solutions if applicable. Finally, ask the user if he/she would like to run the program again. Check case. Let the user input the file name from the keyboard. The program must use lists and recursion for full credit. Refer to the sample output below.
Sample Run:
Enter the file name: elements.txt
This program read words and determines whether a word can be spelled using the symbols from the periodic table.
Enter the word: bananas
Matching bananas:
Solution 1:
[Ba][Na][N][As]:
barium sodium nitrogen arsenic
Solution 2:
[Ba][Na][Na][S]:
barium sodium sodium sulfur
Run again (Y/N): Y
Enter the word: champions
Matching champions:
Solution 1: [
C][H][Am][P][I][O][N][S]:
carbon hydrogen americium phosphorus iodine oxygen nitrogen sulfur
Run again (Y/N): y
84At6 C
Enter the word: north
Matching north:
No element phrase possible.
Run again (Y/N): n
Trending now
This is a popular solution!
Step by step
Solved in 2 steps with 1 images