Results 1 to 7 of 7
  1. #1
    Tripwire is offline Member
    Join Date
    Sep 2008
    Posts
    2
    Rep Power
    0

    Default 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;
    }
    }
    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());
    }
    }
    so the error i'm getting:

    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

  2. #2
    masijade is offline Senior Member
    Join Date
    Jun 2008
    Posts
    2,571
    Rep Power
    9

    Default

    Your constructor is

    Java Code:
    // parameters declared: String String, String, double, double
    public Student(String nm, String me, String stdnr, double prcfr, double ttcfr) {
    Your calling it as
    Java Code:
    // parameters used: String, String, String, String, String
    Student st1 = new Student("Sebastiaan", "Jan Zuurbier", "1556679", "8", "7");
    do you see your problem?

  3. #3
    Tripwire is offline Member
    Join Date
    Sep 2008
    Posts
    2
    Rep Power
    0

    Default

    Ah thx i solved it now. You saved the day :P thx man

  4. #4
    collette15 is offline Member
    Join Date
    Sep 2008
    Posts
    1
    Rep Power
    0

    Default 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..

  5. #5
    DevzAbhi's Avatar
    DevzAbhi is offline Member
    Join Date
    Jul 2008
    Posts
    67
    Rep Power
    0

    Default

    You are missing the sequence of opening or closing {} braces.

    for every opening { brace there should be a corresponding closing } brace.

  6. #6
    loaferwang is offline Member
    Join Date
    Aug 2008
    Posts
    4
    Rep Power
    0

    Default

    I don't know this proterm

  7. #7
    DevzAbhi's Avatar
    DevzAbhi is offline Member
    Join Date
    Jul 2008
    Posts
    67
    Rep Power
    0

    Default

    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

  1. error 530 error authentication required
    By rgale in forum JavaServer Pages (JSP) and JSTL
    Replies: 0
    Last Post: 05-12-2008, 04:28 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •