Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Beginner at Java - can't figure out what I'm doing wrong

  1. #1
    Junior Member
    Join Date
    Oct 2013
    Thanked 0 Times in 0 Posts

    Default Beginner at Java - can't figure out what I'm doing wrong

    Hi all - I am a beginner at this and have been pulling my hair out trying to figure out what I'm doing wrong. My error is on the very last line, 61. I get an error message of "reached end of file while parsing." Can someone please help me understand what I'm doing wrong?


    Student.java file goes with the studentClient.java file

    public class Student {

    private String name;
    private int age;

    //Student Constructor
    public Student (String newName, int newAge) {

    //Mutator method to set student name
    public void setName(String newName) {
    name = newName;
    //Accessor method to get student name
    public String getName() {
    return name;

    //Mutator method to set student age
    public void setAge(int newAge) {
    if (newAge > 0)
    age = newAge;
    System.out.println("Age cannot be negative or zero.");

    //Accessor method to get student age
    public int getAge() {
    return age;

    // method to return name and age of student
    public String fullString() {
    return ("\nName of Student: " + name + "\nAge of Student: " + age + " ");

    //method to determine type of student
    public String typeOfStudent() {
    if (age>0 & age<=4) {
    return "preschool";
    } else {
    if (age>=5 & age<=5) {
    return "kindergarten";
    } else {
    if (age>=6 & age<=10) {
    return "elementary School";
    } else {
    if (age>=11 & age<=13) {
    return "middle school";
    } else {
    if (age>=14 & age<=17) {
    return "high School";
    } else {
    if (age>=18 & age<=100) {
    return "college";
    } else {
    return null;
    } <----- (error on this line)


    public class StudentClient
    public static void main( String [] args )
    Student student1 = new Student("Bob", 15);
    Student student2 = new Student("Jan", 13);
    System.out.println("Name: " + student1.getName());
    System.out.println("Age: " + student1.getAge());
    System.out.println("Type of Student: " + student1.typeOfStudent());

    System.out.println("\n" + student2.fullString());
    System.out.println("Type of Student: " + student2.typeOfStudent());


    System.out.println("\n" + student1.fullString());
    System.out.println("Type of Student: " + student1.typeOfStudent());
    } //ends main
    } //ends program

  2. #2
    Super Moderator
    Join Date
    Jun 2013
    So. Maryland, USA
    My Mood
    Thanked 688 Times in 675 Posts

    Default Re: Beginner at Java - can't figure out what I'm doing wrong

    Please post your code in code tags. Learn how in the Announcement topic at the top of the sub-forum.

    You're missing 7 close braces, '}', after the problem line. This should be obvious in your editor, especially if your code is formatted correctly.

Similar Threads

  1. Replies: 9
    Last Post: March 18th, 2013, 05:49 PM
  2. Can't figure out why this is wrong
    By gabgab96 in forum What's Wrong With My Code?
    Replies: 0
    Last Post: February 26th, 2013, 09:25 PM
  3. Can't figure out what's wrong
    By xdx in forum What's Wrong With My Code?
    Replies: 1
    Last Post: October 10th, 2012, 08:48 AM
  4. Replies: 3
    Last Post: October 19th, 2011, 11:55 PM
  5. i cannot figure out what's wrong
    By biyuss in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 17th, 2011, 09:22 PM