I'm writing a program to get a user to enter their name, and course. I then change the users name to uppercase and get its hashvalue(done that bit).But I have to write another class to store the hashTotal, I've made everything public so far but evrytime I compile the
test program it says
C:\Program Files\Xinox Software\JCreatorV3LE\MyProjects\CourseWork\src\Test.java:12: cannot resolve symbol
symbol : method studentHashList (int)
location: class Student
s.studentHashList(hashTotal);
Here are the Programs
The Student One First
package HashingProblem;
import javax.swing.JOptionPane;
public class Student
{
public
String firstName;
public String surname;
public String name;
public String studentName;
public String studentName1;
public String course;
public int hashTotal;
public int hashValue;
public int asciiValue;
public char letter;
public Student(String name,String course)
{
this.name = name;
this.course = course;
}
public void calculateHash(int nameLength)
{
studentName = (name.toUpperCase());
System.out.println(studentName);
System.out.println(studentName);
if( studentName != null && studentName.length() > 0)
{
for (int i = 0 ;i<studentName.length();i++)
{
letter = studentName.charAt( i ); //get the character from String
asciiValue = letter; //get the ASCII value of the character
hashTotal = hashTotal + asciiValue;
hashValue = hashTotal % studentName.length();
}
System.out.print("The name ;"+ name);
System.out.println("has a hash total is :"+hashTotal);
System.out.println("The hasn value is :"+hashValue);
System.out.println("Student Name is :"+name+" the course they are on is :"+course);
}
}
public String returnName()
{
return name;
}
public String returnCourse()
{
return course;
}
}
the Storage One
package HashingProblem;
import java.util.*;
class Storage
{
int studentList;
int hashTotal;
String name;
Vector studentHashBin = new Vector();
//a constructor to accept the size of the Student object array
public Storage(int studentList)
{
this.studentList = studentList;
}
/* method to add a Student to the Student object array which uses
* the method from the Student object to get the hash index
*/
public void studentHashList(int hashTotal)
{
System.out.println(name+hashTotal);
}
//a method to return the size of the Student object array
//method to output contents of Student array to command line
}
And The Test Program
import javax.swing.JOptionPane;
class Test
{
public static void main(String [] args)
{
int hashTotal;
String name = JOptionPane.showInputDialog("Enter your first Name");
String course = JOptionPane.showInputDialog("Enter your course");
Student s = new Student(name,course);
int nameLength = name.length();
s.calculateHash(nameLength);
s.studentHashList(hashTotal);
System.exit(0);
}
}