The Artima Developer Community
Sponsored Link

Java Answers Forum
Hash table, any ideas??

1 reply on 1 page. Most recent reply: May 9, 2003 10:41 AM by Sharif Ismail

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 1 reply on 1 page
Sharif Ismail

Posts: 2
Nickname: sbaci
Registered: May, 2003

Hash table, any ideas?? Posted: May 9, 2003 7:28 AM
Reply to this message Reply
Advertisement
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();

}}}


Sharif Ismail

Posts: 2
Nickname: sbaci
Registered: May, 2003

Re: Hash table, any ideas?? Posted: May 9, 2003 10:41 AM
Reply to this message Reply
i have fixed it, dont worry, thanks

Flat View: This topic has 1 reply on 1 page
Topic: About operation"+++++" Previous Topic   Next Topic Topic: algorithms

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use