I keep getting these errors in the program below. Here is the assignment: http://www.people.vcu.edu/~dprimeau/cmsc255/fall10/fifthprogram.html

C:\Users\FerretFool0x77>javac Person.java
Person.java:43: illegal start of expression
        public void recordpersonsinhousehold(int x){    //created 11/16/10, modified 11/19/10
        ^
Person.java:43: illegal start of expression
        public void recordpersonsinhousehold(int x){    //created 11/16/10, modified 11/19/10
               ^
Person.java:43: ';' expected
        public void recordpersonsinhousehold(int x){    //created 11/16/10, modified 11/19/10
                                            ^
Person.java:43: ';' expected
        public void recordpersonsinhousehold(int x){    //created 11/16/10, modified 11/19/10
                                                  ^
Person.java:49: illegal start of expression
        public void personreport(){                     //created 11/16/10, modified 11/19/10
        ^
Person.java:49: illegal start of expression
        public void personreport(){                     //created 11/16/10, modified 11/19/10
               ^
Person.java:49: ';' expected
        public void personreport(){                     //created 11/16/10, modified 11/19/10
                                ^
7 errors

Program:

import java.util.Scanner;

class Person{   //created and modified: 11/16/10

    int gender=0;
    int age=0;
    int marriedstatus=0;
    double familyincome=0;
    String maxeducation;
    int personsinhousehold=0;

    public void recordgender(int x){        //created 11/16/10, modified 11/19/10
    }

    public void recordage(int x){           //created 11/16/10, modified 11/19/10   
    }

    public void recordmarriedstatus(int x){     //created 11/16/10, modified 11/19/10
    }

    public void recordfamilyincome(double x){   //created 11/16/10, modified 11/19/10
    }

    //end of simple

    public void recordmaxeducation(int x){      //created 11/16/10, modified 11/19/10
        //System.out.print("Highest level of education: ");
        this.maxeducation=x;
        switch (maxeducation){
            case 0:
                maxeducation=("no HS diploma");
            break;
            case 1:
                maxeducation=("HS diploma");
            break;
            default:
                maxeducation=("college");
            break;
    }

    public void recordpersonsinhousehold(int x){    //created 11/16/10, modified 11/19/10
        this.personsinhousehold=x;
        if (x<1)
            x=1;
    }

    public void personreport(){         //created 11/16/10, modified 11/19/10

        System.out.println("***********************");
        System.out.println("This person's data includes: ");

        System.out.print("Gender: ");
        if (gender==0)
            System.out.println("unreprorted");
        if (gender==1)
            System.out.println("male");
        if (gender==2)
            System.out.println("female");

        System.out.println("Age: "+age);

        System.out.println("Family income: $"+familyincome);

        System.out.println("Highest level of education: "+maxeducation);


        System.out.println("Total number of family members indicates");
        if (personsinhousehold>2 && personsinhousehold<5)
            System.out.println("average sized household");
        if (personsinhousehold==1 || personsinhousehold==2)
            System.out.println("smaller than average household");
        else
            System.out.println("larger than average sized household");

        }

    }
}

public class Getpersoninfo{ //created and modified: 11/16/10
    public static void main(String args[]){ //created and modified: 11/16/10

        Person name = new Person();

        int householdsize=1;    // set default value to 1 since at least the interviewed person lives in the household
        int gender=0;       // 0 = unreported; 1 = male; 2 = female
        int married=0;      // 0 = unreported; 1 = single; 2 = married; 3 = divorced
        int age=0;
        double totalincome=0;   // total household income
        int maxeducation=0;     // 0 = no HS diploma; 1 = HS diploma; 2 = college

        name.recordpersonsinhousehold(householdsize);
        name.recordgender(gender);
        name.recordage(age);
        name.recordmarriedstatus(marriedstatus);
        name.recordfamilyincome(familyincome);
        name.recordmaxeducation(maxeducation);
        personreport();

    }
}

"Illegal start of expression" usually means you haven't closed out a block - you owe some curly braces. In this case, you go to the line that's cited and look at what's going on just before there. Well, it's a method declaration, you can't declare a method inside another method. Sure enough, look at the previous method and you have two left braces - opening the method and the switch - and only one right brace. So you're still in the previous method, and you can't declare a new one.
Add a right brace to finish the method.

And the problem you'll have next is that you're assigning an int into a String - legal - and then trying to use it in a switch - illegal. Once it's cast to a String, it's no longer an integer primitive (char, int, long, short).
The simplest solution to that is to delete the assignment (this.maxeducation=x) and switch on x, not maxeducation.

There may be other problems, but that'll get you a little way down the road.
Next time, please use the code tags for legibility and if you could just camelCase those variableNames I'd loveLoveLove it, thanks.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.