Results 1 to 7 of 7
Thread: Getting an error :(
- 09-21-2008, 10:30 PM #1
Member
- Join Date
- Sep 2008
- Posts
- 2
- Rep Power
- 0
Getting an error :(
Hi guys i'm a student and i'm new to java (and this forum). I've wrote a program for a school assignment, the problem is i'm getting an error and i don't know why or how to solve it. So i hope you guys can help me.
So here is the program:
public class Student {
private String naam;
private String mentor;
private String studentnr;
private double practicumcijfer;
private double tentamencijfer;
private double gemiddelde;
public Student(String nm, String me, String stdnr, double prcfr, double ttcfr) {
naam = nm; mentor = me; studentnr = stdnr; practicumcijfer = prcfr; tentamencijfer = ttcfr;
}
public void setmentor(String me) {
mentor = me;
}
public void setpracticumcijfer(double prcfr) {
practicumcijfer = prcfr;
}
public void settentamencijfer(double ttcfr) {
tentamencijfer = ttcfr;
}
public String getNaam() {
return naam;
}
public String getstudentnr() {
return studentnr;
}
public double getgemiddelde() {
gemiddelde = (tentamencijfer + practicumcijfer) / 2;
return gemiddelde;
}
public String toString() {
String a = "De Student heet \n " + naam;
a = a + "\nzijn mentor is \n" + mentor;
a = a + "\nzijn studentnummer is \n" + studentnr;
a = a + "\nzijn practicumcijfer is een \n" + practicumcijfer;
a = a + "\nzijn tentamencijfer is een \n" + tentamencijfer;
a = a + "\nzijn gemiddelde cijfer is een \n" + gemiddelde;
return a;
}
}so the error i'm getting:public class Main {
public static void main(String[] arg) {
Student st1 = new Student("Sebastiaan", "Jan Zuurbier", "1556679", "8", "7");
Student st2 = new Student("Jacob", "Jan Zuurbier", "1234567", "7", "8");
System.out.println(st1.getNaam());
System.out.println(st2.getNaam());
System.out.println(st1.getgemiddelde());
System.out.println(st2.getgemiddelde());
System.out.println(st1.toString());
System.out.println(st2.toString());
}
}
Main.java:3: cannot find symbol
symbol : constructor Student(java.lang.String,java.lang.String,java.lan g.String,java.lang.String,java.lang.String)
location: class Student
Student st1 = new Student("Sebastiaan", "Jan Zuurbier", "1556679", "8", "7");
^
Main.java:4: cannot find symbol
symbol : constructor Student(java.lang.String,java.lang.String,java.lan g.String,java.lang.String,java.lang.String)
location: class Student
Student st2 = new Student("Jacob", "Jan Zuurbier", "1234567", "7", "8");
^
2 errors
- 09-21-2008, 10:43 PM #2
Senior Member
- Join Date
- Jun 2008
- Posts
- 2,366
- Rep Power
- 7
Your constructor is
Your calling it asJava Code:// parameters declared: String String, String, double, double public Student(String nm, String me, String stdnr, double prcfr, double ttcfr) {
do you see your problem?Java Code:// parameters used: String, String, String, String, String Student st1 = new Student("Sebastiaan", "Jan Zuurbier", "1556679", "8", "7");
- 09-21-2008, 10:51 PM #3
Member
- Join Date
- Sep 2008
- Posts
- 2
- Rep Power
- 0
Ah thx i solved it now. You saved the day :P thx man
- 09-24-2008, 09:06 AM #4
Member
- Join Date
- Sep 2008
- Posts
- 1
- Rep Power
- 0
errors,errors,errors,
hi guys,,,im a college student and im having a hard time with my programming course...one of the error i always encountered is "class, interface, enum expected" need help guys...hope u can help me...thnx..
- 09-24-2008, 09:21 AM #5
You are missing the sequence of opening or closing {} braces.
for every opening { brace there should be a corresponding closing } brace.
- 09-24-2008, 01:16 PM #6
Member
- Join Date
- Aug 2008
- Posts
- 4
- Rep Power
- 0
I don't know this proterm
- 09-24-2008, 01:22 PM #7
actually when ever your are writing a code in java you enclose every thin in blocks
eg
public class ClassName{//opening braces
void method()
{//opening braces
.............;// your code goes here
.............;
}//closing braces
}//closing braces
if you miss these you tend to get the above mentioned errors.
Similar Threads
-
error 530 error authentication required
By rgale in forum JavaServer Pages (JSP) and JSTLReplies: 0Last Post: 05-12-2008, 04:28 PM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks