import java.io.*; public class ChemApp { public static void main(String []args) throws IOException{ //Declare and creat array to store the names of the elements String[] name = {"","hydrogen","helium","lithium","beryllium","boron","carbon"}; //Declare and creat array to store the symbols for the elements String[] symbol = {"","H","He","Li","Be","B","C"}; //Declare and creat array to store average molar masses for the elements double[] mass = {0.0,1.01, 4.00, 6.94, 9.01, 10.81, 12.01}; //Define input variable to read from keyboard BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); //Define variable to store index provided by user int input; //Prompt user for an index number System.out.println("Please input element number: "); input = Integer.parseInt(in.readLine()); //Display the result System.out.println(); System.out.println("Element number " + input + " is " + name[input] + " (symbol = " + symbol[input] + ") with average molar mass of " + mass[input] + " g/mol."); } }