hello im trying to write an analzyer using a hash table, but i cant get it to work, i think ive gone wrong where the stars are, when you have to save them to positions, (code below), Any ideas to solve the problem, thank you
public class test { /*Chemical Analzyer Author: Me Version: 1.0 Date: 05/05/03*/
public static void main(String[]args) { //define variables int Second, Sum, FirstNext; String Place;
System.out.println(); System.out.println("Welcome to my Chemcial Analzyer"); System.out.println(); // Ask user to enter a Chemical String FullChem=WinKBInput.readString("Please can you enter the Chemical you wish to be analzeyed"); //Convert string FullChem to upper case String FullChem2=FullChem.toUpperCase(); * * * * * * * { //Print full chemcial on the output screen System.out.println(); System.out.println("You entered this Chemical: "+FullChem2); System.out.println();
//Hashtable -> storing of objects that have a relationship with a key int PlaceElements=20; //Array 1 declares first key String Keys[]={"AG","AL","C","AU","C","CA","CL","CU","CO","H","HE","HG","K","MG","N"," NA","O","PB","S","XE"}; //Array 2 declares place of chemcial String ChemNames[]={"Silver","Aluminium","Gold","Carbon","Calcuim","Chlorine", "Copper ","Cobolt","Hydrogen", "Helium","Mercury","Potassium ","Magnesium ","Nitrogen", "Sodium ","Oxygen ","Phosporus ","Lead ","Sulphur","Xenon"}; Hashtable ht; ht=new Hashtable(PlaceElements*2); for (int i=0; i<PlaceElements;i++) ht.put(Keys, new String(ChemNames)); //Outputs the full chemical name System.out.println("The chemcial you enter was: "+ht.get(ChemName)); System.out.println();