help with ?

I have a project made and it has 2 classes one called student and one called main. It keeps throwing me an error on line 12 of the main class I have no idea why and i cant figure it out can someone help please. Thanks in advance

here is the student class

========================================================

import javax.swing.JOptionPane;

class student

{ //Opening brace for MyWorld class

private String studentName;//Holds first name

private Double studentGpa;//Holds last name

/*****

* Default constructor for MyWorld class prompts user for initial value

* of the object.

*****/

public student()

{//Opening brace for MyWorld()

String input;

studentName = JOptionPane.showInputDialog(null, "Enter your first name:",

"PracticeLab1", JOptionPane.QUESTION_MESSAGE);

input = JOptionPane.showInputDialog(null, "Enter GPA:",

"PracticeLab1", JOptionPane.QUESTION_MESSAGE);

studentGpa = Double.valueOf(input);

}//Closing brace for MyWorld()

/*****

* Overloaded constructor for MyWorld class that will set instant

* variables to values received by the parameter.

*****/

public student(String pStudentName, Double pStudentGpa)

{//Opening brace for MyWorld() overloaded

studentName = pStudentName;

studentGpa = pStudentGpa;

}//Closing brace for MyWorld() overloaded

/*****

* getFirstName() method will return the current value in firstName

*****/

public String getStudentName()

{//Opening brace for getFirstName()

return studentName;

}//Closing brace for getFirstName()

/*****

* getLastName() method will return the current value in lastName

*****/

public Double getStudentGpa()

{//Opening brace for getLastName()

return studentGpa;

}//Closing brace for getLastName()

/*****

* setFirstName() method will replace the current value in firstName

*****/

public void setStudentName(String pStudentName)

{//Opening brace for setFirstName()

studentName = pStudentName;

}//Closing brace for setFirstName()

/*****

* setLastName() method will replace the current value in lastName

*****/

public void setStudentGpa(Double pStudentGpa)

{//Opening brace for setLastName()

studentGpa = pStudentGpa;

}//Closing brace for setLastName()

/*****

* displayMessage() method displays the data in a message box

*****/

public void displayMessage()

{//Opening brace for displayMessage()

String output;

output = "Name: " + studentName +

"\nGPA: " + studentGpa;

JOptionPane.showMessageDialog(null, output, "PracticeLab1",

JOptionPane.INFORMATION_MESSAGE);

}//Closing brace for displayMessage()

/*****

* outputMessage() method displays the data using the

* System.out.println() method

*****/

public void outputMessage()

{//Opening brace for outputMessage()

System.out.println("Name: " + studentName);

System.out.println("GPA: " + studentGpa);

}//Closing brace for outputMessage()

} //Closing brace for MyWorld class

=======================================================

here is the main class

=======================================================

class PracticeLab1

{ //Opening brace for PracticeLab1 class

public static void main(String[] args)

{//Opening brace for main()

student stu1 = new student("sean", 4.0); //here is where it is throwing the error.

student stu2 = new student();

System.out.println(stu1.getStudentName() + " " +

stu1.getStudentGpa() + " " );

System.out.println();

stu2.outputMessage();

System.out.println();

stu2.outputMessage();

System.out.println();

stu1.displayMessage();

System.out.println("\n\nEnd of the PracticeLab1 application.");

}//Closing brace for main()

} //Closing brace for PracticeLab1 class

======================================================

[4158 byte] By [quarinteena] at [2007-10-2 20:09:14]
# 1

First, What is the exact error the compiler shows. It usually very detailed about what it doesnt like.

Second, when posting code, please use the [code] and [/code] tags. it will make your source much easier to read..

[url=http://forum.java.sun.com/help.jspa?sec=formatting]Please follow these formatting tips.[/url]

JJ

Java_Jaya at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 2
And third, which line is line 12?
DrClapa at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 3
> And third, which line is line 12?My guess is this line: student stu1 = new student("sean", 4.0); //here is where it is throwing the error.
dwga at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 4

If I had to guess, which I suppose I do since you haven't provided what the error is, is that the error is caused by the fact that you are not using Java 5.0 and thus the double 4.0 is not autoboxed to a Double (note that double and Double are not the same) .. tryclass student

{

// ...

private double studentGpa;

// ...

public student(String pStudentName, double pStudentGpa)

// ...

ps. watch out for copy paste errors: public student()

{ //Opening brace for MyWorld()

and other similar things. BTW, those comments on which opening brace it is are quite redundant.

dwga at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 5

It says

"scottOliverLabWeek1.java": cannot find symbol; symbol : constructor student(java.lang.String,double), location: class student at line 12, column 24

"scottOliverLabWeek1.java": internal error; cannot instantiate student.<init> at student to () at line 12, column 24

. Yes that was line 12. the

student stu1 = new student ("sean", 4.0);

quarinteena at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 6
Which is what I thought, see my reply #4.
dwga at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 7

> It says

>

> "scottOliverLabWeek1.java": cannot find symbol;

> symbol : constructor

> student(java.lang.String,double), location: class

> student at line 12, column 24

>

>

> "scottOliverLabWeek1.java": internal error; cannot

> instantiate student.<init> at student to () at line

> 12, column 24

>

> . Yes that was line 12. the

>

> student stu1 = new student ("sean", 4.0);

Also, common practice and standards dictate you have one class per java file and the file name must match the class name exactly. Your student class should be capitalized....

From what you posted you should have two source files... Student.java for the class Student{ }and a file named PracticeLab1.java for the class PracticeLab1{ }.

Clear?

JJ

Java_Jaya at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 8
my class name is student so are the others with no capitol if I try to change it to cap it throws an error. Also If i change everything from Double to int it gives the same error..Also I have 5.0, I thought that might be it and it was not.Message was edited by:
quarinteena at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...
# 9

> my class name is student so are the others with no

> capitol if I try to change it to cap it throws an

> error.

If you rename the class from student to Student, you must also change the filename to Student.java and also make sure that every time you reference the class that you use the correct name, eg Student.

for example, I have a file called Foo.java and it looks like this:

// -- The class name is the same as the file --

public class Foo {

private String name;

public Foo(String s) { //<-- The constructor has the same name

this.name = s;

}

public static void main (String[] args) {

Foo f = new Foo("Smith"); //<-- The class instantiation uses the same name

System.out.println("This opbject name is: " + f.name);

}

}

The point is, every place you need the class name, it must match everywjere.

> Also If i change everything from Double to int

> it gives the same error..

Then just downcast when declaring the array.

long m = 5.0;

long n = 6.0;

// the following will give you a 5x6 array of ints..

int[] iArray = new int[(int)m] [(int)n];

> Also I have 5.0, I thought that might be it and it

> was not.

Nope, JDK 5.0 has nothing to do with it.

I suggest you look over some of these links.

[url=http://java.sun.com/j2se/1.5.0/install-windows.html]Installation Notes - JDK 5.0 Microsoft Windows (32-bit)[/url]

[url=http://java.sun.com/docs/books/tutorial/getStarted/cupojava/index.html]Your First Cup of Java[/url]

[url=http://java.sun.com/docs/books/tutorial/]The Java?Tutorial - A practical guide for programmers[/url]

[url=http://java.sun.com/learning/new2java/index.html]New to Java Center[/url]

[url=http://leepoint.net/notes-java/index.html]Java Programming Notes - Fred Swartz[/url]

[url=http://www.ibiblio.org/obp/thinkCSjav/]How To Think Like A Computer Scientist[/url]

[url=http://chortle.ccsu.ctstateu.edu/CS151/cs151java.html]Introduction to Computer science using Java[/url]

[url=http://javaalmanac.com/]The Java Developers Almanac 1.4[/url]

[url=http://java.sun.com/docs/books/tutorial/java/concepts/]Object-Oriented Programming Concepts[/url]

[url=http://www.javaworld.com/javaworld/jw-04-2001/jw-0406-java101.html]Object-oriented language basics[/url]

[url=http://sepwww.stanford.edu/sep/josman/oop/oop1.htm]Don't Fear the OOP[/url]

Free Java Books

[url=http://mindview.net/Books/DownloadSites]Thinking in Java[/url], by Bruce Eckel (Free online)

[url=http://pdf.coreservlets.com/]Core Servlet Programming[/url], by Merty Hall (Free Online)

[url=http://pdf.moreservlets.com/]More Servlets[/url], by Marty Hall (Free Online)

[url=http://www.scism.sbu.ac.uk/jfl/jibook/]A Java GUI Programmer's Primer[/url]

[url=http://www.brpreiss.com/books/opus5/html/book.html]Data Structures and Algorithms

with Object-Oriented Design Patterns in Java[/url], by Bruno R. Preiss

[url=http://www.andamooka.org/reader.pl?section=javanotes]Introduction to Programming Using Java[/url], by David J. Eck

[url=http://java.sun.com/developer/onlineTraining/Programming/JDCBook/index.html]Advanced Programming for the Java 2 Platform[/url]

[url=http://java.sun.com/docs/books/jls/]The Java Language Specification[/url]

Cheers!

JJ

Java_Jaya at 2007-7-13 22:49:44 > top of Java-index,Java Essentials,New To Java...