I've been working on a homework assignment for a while now for my class, and right now I'm stuck on what should be a very simple problem. I have two files, EmployeeSystem.java and FullTimeEmployee.java. EmployeeSystem is the main, and is the file currently failing to compile. Basically in the method loadData() the setZip method is not working because it says 'cannot find symbol' on that particular value. I have looked and looked over FullTimeEmployee and this trying to find out what I am doing wrong, to no avail. Originally zip was an int but I changed it to a string for what I thought was more logical functionality, and to see if that would help it work.

Does anyone see why this would be failing compile?

EmployeeSystem

/**
 * EmployeeDirectorySystem class works as 
 * the main controlling system for 
 * accessing full time employee objects.
 * CSCE 155 Fall 2008
 * Assignment 2
 * @author
 * @version
 */

// import statements
import java.io.*;
import java.util.*;

public class EmployeeDirectorySystem  {
    
    // -------------------------------------------------------------------------
    // You may add more data members to the following to describe a 
	// directory system.
    // -------------------------------------------------------------------------
    
    // private data members -- variables
    private FullTimeEmployee employee1, employee2, employee3; 
    private FullTimeEmployee employee4, employee5, employee6; 
    private FullTimeEmployee employee7, employee8, employee9; 
    private FullTimeEmployee employee10, employee11, employee12; 
	 
    
    // -------------------------------------------------------------------------
    // Here are the public and private methods that specify the system.
    // First of all, a employee object will provide information for you, will
    // allow you to change its settings, and will also do quite a bit of other
    // things.  You may add new methods.
    // -------------------------------------------------------------------------
    
    /** Constructor
     *  initialize all private data members to appropriate values
     *  If you add more data members, you will have to initialize them here
     *  too.
     */
    public EmployeeDirectorySystem()  {  
    	employee1 = new FullTimeEmployee();
    	employee2 = new FullTimeEmployee();
    	employee3 = new FullTimeEmployee();
    	employee4 = new FullTimeEmployee();
    	employee5 = new FullTimeEmployee();
    	employee6 = new FullTimeEmployee();
    	employee7 = new FullTimeEmployee();
    	employee8 = new FullTimeEmployee();
    	employee9 = new FullTimeEmployee();
    	employee10 = new FullTimeEmployee();
    	employee11 = new FullTimeEmployee();
    	employee12 = new FullTimeEmployee();
    }  // end constructor
    
    
    //--------------------------------------------------------------------------
    // Please Complete the runPayroll method below
    // This method will run individual payrolls on the employee depending on 
    // the choice entered by the user.
    //--------------------------------------------------------------------------
    public void runDirectory(){
        
 		System.out.println("Please enter all or part of the employee name:");
		
		System.out.println("Please enter all or part of the employee ID");
		
		System.out.println("Please enter all or part of the employee phone number:");
		
		// 2. Determine if you can find a specific employee, if not, ask the 
    	//    user for more information to help determine the employee.
		
		// 3. Once determined, display all of the information regarding 
    	//    the employee.

    }//end of runDirectory
    
    
    /**
     * This method displays a welcome message to the user.
     */
    public void displayWelcome()  {
        
    	/* Display a brief welcome message about the system */
    	System.out.println("Welcome to the CSE Employee Directory");
		System.out.println("You can view information about an employee by using this system");
        
    }  // end displayWelcome
    
    /**
     * This method displays a goodbye message to the user.
     */
    public void displayGoodbye()  {
        
        /* Display a brief goodbye message from the system */
        
    }  // end displayGoodbye
    
    /**
     * This method loads the employee information.  
     */
    public void loadData()  {
    	employee1.setEmployeeName("Jeffery Johnson");
    	employee1.setEmployeeID("A001");
    	employee1.setDateOfBirth(new GregorianCalendar(1978, Calendar.JUNE, 14));
    	employee1.setStartDate(new GregorianCalendar(2006, Calendar.AUGUST, 1));
    	employee1.setPhoneNumber("402-486-5104");
    	employee1.setStreetAddress("123 14th Street");
    	employee1.setCity("Lincoln");
    	employee1.setState("Nebraska");
    	employee1.setZIP("68588");
    	employee1.setMonthlySalary(1400);
    	
    	employee2.setEmployeeName("Jeffery Smith");
    	employee2.setEmployeeID("B002");
    	employee2.setDateOfBirth(new GregorianCalendar(1973, Calendar.SEPTEMBER, 12));
    	employee2.setStartDate(new GregorianCalendar(1999, Calendar.JANUARY, 3));
    	employee2.setPhoneNumber("402-357-5104");
    	employee2.setStreetAddress("321 4th Street");
    	employee2.setCity("Seward");
    	employee2.setState("Nebraska");
    	employee2.setZIP("68801");
    	employee2.setMonthlySalary(1350);
    	
    	employee3.setEmployeeName("Jessica Smith");
    	employee3.setEmployeeID("A303");
    	employee3.setDateOfBirth(new GregorianCalendar(1974, Calendar.NOVEMBER, 21));
    	employee3.setStartDate(new GregorianCalendar(2003, Calendar.FEBRUARY, 14));
    	employee3.setPhoneNumber("402-408-6693");
    	employee3.setStreetAddress("220 Wenzel Circle");
    	employee3.setCity("Eagle");
    	employee3.setState("Nebraska");
    	employee3.setZIP("68347");
    	employee3.setMonthlySalary(2200);
    	
    	employee4.setEmployeeName("Jeremy Suing");
    	employee4.setEmployeeID("X001");
    	employee4.setDateOfBirth(new GregorianCalendar(1975, Calendar.JUNE, 5));
    	employee4.setStartDate(new GregorianCalendar(2005, Calendar.MAY, 16));
    	employee4.setPhoneNumber("402-472-1658");
    	employee4.setStreetAddress("640 N. 14th Street");
    	employee4.setCity("Lincoln");
    	employee4.setState("Nebraska");
    	employee4.setZIP("68588");
    	employee4.setMonthlySalary(50);
    	
    	employee5.setEmployeeName("Sally Smith");
    	employee5.setEmployeeID("B001");
    	employee5.setDateOfBirth(new GregorianCalendar(1980, Calendar.JANUARY, 11));
    	employee5.setStartDate(new GregorianCalendar(2006, Calendar.AUGUST, 1));
    	employee5.setPhoneNumber("402-357-3798");
    	employee5.setStreetAddress("55894 893rd Road");
    	employee5.setCity("Fremont");
    	employee5.setState("Nebraska");
    	employee5.setZIP("68321");
    	employee5.setMonthlySalary(1400);
    	
    	employee6.setEmployeeName("John Johnson");
    	employee6.setEmployeeID("B010");
    	employee6.setDateOfBirth(new GregorianCalendar(1979, Calendar.JUNE, 14));
    	employee6.setStartDate(new GregorianCalendar(2000, Calendar.AUGUST, 1));
    	employee6.setPhoneNumber("402-486-5110");
    	employee6.setStreetAddress("123 14th Street");
    	employee6.setCity("Lincoln");
    	employee6.setState("Nebraska");
    	employee6.setZIP("68588");
    	employee6.setMonthlySalary(1450);
    	
    	employee7.setEmployeeName("Sarah Smith");
    	employee7.setEmployeeID("B200");
    	employee7.setDateOfBirth(new GregorianCalendar(1974, Calendar.OCTOBER, 14));
    	employee7.setStartDate(new GregorianCalendar(1997, Calendar.JANUARY, 31));
    	employee7.setPhoneNumber("402-408-5104");
    	employee7.setStreetAddress("321 4th Street");
    	employee7.setCity("Utica");
    	employee7.setState("Nebraska");
    	employee7.setZIP("68701");
    	employee7.setMonthlySalary(1550);
    	
    	employee8.setEmployeeName("John Doe");
    	employee8.setEmployeeID("A678");
    	employee8.setDateOfBirth(new GregorianCalendar(1981, Calendar.MARCH, 28));
    	employee8.setStartDate(new GregorianCalendar(1998, Calendar.MARCH, 2));
    	employee8.setPhoneNumber("303-804-1169");
    	employee8.setStreetAddress("6009 Kingsley Ave.");
    	employee8.setCity("Littleton");
    	employee8.setState("Colorado");
    	employee8.setZIP("80104");
    	employee8.setMonthlySalary(4100);
    
    	employee9.setEmployeeName("Tad Jacobs");
    	employee9.setEmployeeID("X222");
    	employee9.setDateOfBirth(new GregorianCalendar(1975, Calendar.JULY, 1));
    	employee9.setStartDate(new GregorianCalendar(2003, Calendar.AUGUST, 16));
    	employee9.setPhoneNumber("719-555-5555");
    	employee9.setStreetAddress("7979 Technology Way");
    	employee9.setCity("Denver");
    	employee9.setState("Colorado");
    	employee9.setZIP("80237");
    	employee9.setMonthlySalary(3333);
    	
    	employee10.setEmployeeName("Ella Roberts");
    	employee10.setEmployeeID("B501");
    	employee10.setDateOfBirth(new GregorianCalendar(1983, Calendar.SEPTEMBER, 4));
    	employee10.setStartDate(new GregorianCalendar(2006, Calendar.MAY, 10));
    	employee10.setPhoneNumber("402-472-1100");
    	employee10.setStreetAddress("5567 Adams Street");
    	employee10.setCity("Lincoln");
    	employee10.setState("Nebraska");
    	employee10.setZIP("68521");
    	employee10.setMonthlySalary(2400);
    	
    	employee11.setEmployeeName("Ellen Smith");
    	employee11.setEmployeeID("A501");
    	employee11.setDateOfBirth(new GregorianCalendar(1982, Calendar.AUGUST, 24));
    	employee11.setStartDate(new GregorianCalendar(2001, Calendar.MARCH, 19));
    	employee11.setPhoneNumber("402-472-2200");
    	employee11.setStreetAddress("567 9th Street");
    	employee11.setCity("Lincoln");
    	employee11.setState("Nebraska");
    	employee11.setZIP("68520");
    	employee11.setMonthlySalary(3400);
    	
    	employee12.setEmployeeName("Bobby Smith");
    	employee12.setEmployeeID("B555");
    	employee12.setDateOfBirth(new GregorianCalendar(1983, Calendar.DECEMBER, 4));
    	employee12.setStartDate(new GregorianCalendar(2006, Calendar.OCTOBER, 10));
    	employee12.setPhoneNumber("402-470-1200");
    	employee12.setStreetAddress("9876 34th Ave.");
    	employee12.setCity("Lincoln");
    	employee12.setState("Nebraska");
    	employee12.setZIP("68527");
    	employee12.setMonthlySalary(240);
    	
    }  // end loadData
    
    /**
     * This method reads an integer and
     * returns that integer to the caller of this method.
     */
    private int readInteger()  {
        
        int temp = 0;
        
        Scanner scanner = new Scanner(System.in);
        
        try {
            temp = scanner.nextInt();  // read integer
        }  catch (InputMismatchException ex) {
            System.out.println(ex);
        }
        
        return temp;
        
    }  // end readInteger
    
    /**
     * This method reads in a string and returns that string to the caller of
     * this method.
     */
    private String readString()  {
        
        String userInput = "";
        
        Scanner scanner = new Scanner(System.in);
        
        userInput = scanner.nextLine();
        
        return userInput;
        
    }  // end readString

    /**
     * This main method creates an object of the EmployeeDirectorySystem class 
     * and runs the Employee Directory System. 
     *
     * First, it asks the EmployeeDirectorySystem object to display a welcome 
     * message. Then it loads the employee data. Next, it asks the 
     * EmployeeDirectorySystem object to run the directory. Finally, it asks 
     * the EmployeeDirectorySystem object to display a goodbye message.
     */
    public static void main(String[] args)  {

    	EmployeeDirectorySystem mySystem = new EmployeeDirectorySystem();
    	mySystem.displayWelcome();
    	mySystem.loadData();
    	mySystem.runDirectory();
    	mySystem.displayGoodbye();
                                     
    }  // end main
}  // end Class EmployeeDirectorySystem

FullTimeEmployee

/*
 * FullTimeEmployee.java
 *
 * CSCE 155 Fall 2008
 * Assignment 2
 * @author
 * @version
 */

// import statements
import java.util.*;

/**
 * Used to store information of the full time employee.  It can also be used
 * to calculate the pay for a full time employee.
 * 
 * @author
 * @version
 */

public class FullTimeEmployee {
    
    // -------------------------------------------------------------------------
    // You may add more data members to the following to describe a Full Time 
	// Employee.  You may need to remove some data members as well.
    // -------------------------------------------------------------------------

	//------------------Declare Constants---------------------------------------
    
    /**
     * Represents the percentage of the federal tax
     */
    private final double FEDERAL_TAX_PERCENT = 0.15; 
    
    /**
     * Represents the percentage of the health insurance deduction
     */
    private final double HEALTH_INSURANCE_PERCENT = 0.05;   

    /**
     * Represents the percentage of the Retirement Savings deduction
     */
    private final double RETIREMENT_SAVINGS_PERCENT = 0.12;   

    /**
     * Represents the percentage of the state tax
     */
    private final double STATE_TAX_PERCENT = 0.08;   
    
    //-------------Declare private variables-----------------------------------
    
    /**
     *variables used to hold the values for various information
	  *about the employee including name, ID, phone number, street address,
	  *city, state, and zip code
     */
    private String 	employeeName; 	
	 private String	employeeID;
	 private String phoneNumber;
	 private String streetAddress;
	 private String city;
	 private String state;
	 private String zip;
	 
    /**
     * Represents the amount in dollars of the salary for the employee
     */
    private int 	monthlySalary; 	
    /**
     * Represents the date of employment
     */
    private GregorianCalendar 	startDate; 
	 /**
	 * Represents the birth date for the employee
	 */		
	 private GregorianCalendar		dateOfBirth;
	 /**
	 * Various variables used to calculate pay deductions for the method
	 *calculateNetMonthly() used to calculate net pay for the employee
	 */
	 	  private double deductionFederalTax;
		  private double deductionStateTax;
		  private double deductionRetirement;
		  private double deductionHealth;
        
    /**
     * Constructor used to create this object.  Responsible for setting
     * all of this object's information to their corresponding default values
     */
    public FullTimeEmployee(){
        this.employeeName = "";
        this.employeeID = "";
		  this.phoneNumber = "";
		  this.streetAddress = "";
		  this.city = "";
		  this.state = "";
		  this.zip = "";
    }//end of constructor
    
    /**
     * Returns the employee's name from this object 
     * @return <code>String</code> Name of the Employee represented in object
     */
	public String getEmployeeName() {
		return employeeName;
	}
	public String getEmployeeID() {
		return employeeID;
	}
	public String getPhoneNumber() {
		return phoneNumber;
	}
	public String getStreetAddress(String streetAddress) {
		return streetAddress;
	}
	public String getCity(String city) {
		return city;
	}
	public String getState(String state) {
		return state;
	}
	public String getZip(String zip) {
		return zip;
	}

	public int getMonthlySalary(int monthlySalary) {
		return monthlySalary;
	}
    /**
     * Sets the employee name represented by this object
     * @param employeeName the name of the employee
     */
	public void setEmployeeName(String employeeName) {
		this.employeeName = employeeName;
	}
	public void setEmployeeID(String employeeID) {
		this.employeeName = employeeID;
	}
	public void setPhoneNumber(String phoneNumber) {
		this.employeeName = phoneNumber;
	}
	public void setStreetAddress(String streetAddress) {
		this.streetAddress = streetAddress;
	}
	public void setCity(String city) {
		this.city = city;
	}
	public void setState(String state) {
		this.state = state;
	}
	public void setZip(String zip) {
		this.zip = zip;
	}
	
	public void setDateOfBirth(GregorianCalendar dateOfBirth) {
		this.dateOfBirth = dateOfBirth;
	}
	public void setStartDate(GregorianCalendar startDate) {
		this.startDate = startDate;
	}
	
	public void setMonthlySalary(int monthlySalary) {
		this.monthlySalary = monthlySalary;
	}

    /**
	 * calculateNetMonthly calculates the net pay for the employee by
	 * subtracting the deductions for Federal Tax, State Tax, Retirement
	 * savings, and health insurance from the gross pay
	 */
    public double calculateNetMonthly(){
        deductionFederalTax = (monthlySalary * FEDERAL_TAX_PERCENT);
		  deductionStateTax = (monthlySalary * STATE_TAX_PERCENT);
		  deductionRetirement = (monthlySalary * RETIREMENT_SAVINGS_PERCENT);
		  deductionHealth = (monthlySalary * HEALTH_INSURANCE_PERCENT);
		  
        double netPay = 0.0;
    	return netPay;
    }//end of calculateNetMonthly
    
	 /**
	 * display() prints out all information about the employee
	 */
    public void display(){
        System.out.println("Displaying Information for Employee:");
		  System.out.println("Employee ID: " + employeeID);
		  System.out.println("Employee name: " + employeeName);
		  System.out.println("Date of birth: " + dateOfBirth);
		  System.out.println("Date of employment: " + startDate);
		  System.out.println("Employee phone number: " + phoneNumber);
		  System.out.println("Employee street address: " + streetAddress);
		  System.out.println("Employee city, state, and zip: " + city + ", " + state + " " + zip);
		  System.out.println("The gross pay of the employee is: " + monthlySalary);
		  
		  
    }//end of display      
}//end of class FullTimeEmployee

Recommended Answers

All 3 Replies

The name of the file must be the same as the name of the class and as the name of the constructor. That is why in java terminology we don't say 'file' but 'class'

Is the name of the file: EmployeeSystem ?

Then this :

public class EmployeeDirectorySystem  {

  public EmployeeDirectorySystem()  {  

  }
}

Should be:

public class EmployeeSystem {

  public EmployeeSystem ()  {  

  }
}

Or change the name of the file

Plus next time say the line where the error happens as well as the full message of the compiler

No EmployeeSystem was just a typo by me, the actual file is called EmployeeDirectorySystem and it works just fine. If it didn't then all the other values would also still have compiler errors. The problem is something to do with the setZip method. When the compiler reaches that method in the loadData() method in java, I get 12 compiler errors, 1 for each employee object. Originally the homework had 100 compiler errors until I inserted the missing set methods in FullTimeEmployee. Everything compiled then except the set Zip method, and I cannot figure out for the life of me what makes this particular value so different.

I suspect the answer is very simple and obvious to everyone but me.

Here is the full compiler message.

EmployeeDirectorySystem.java:111: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee1.setZIP("68588");
    	         ^
EmployeeDirectorySystem.java:122: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee2.setZIP("68801");
    	         ^
EmployeeDirectorySystem.java:133: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee3.setZIP("68347");
    	         ^
EmployeeDirectorySystem.java:144: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee4.setZIP("68588");
    	         ^
EmployeeDirectorySystem.java:155: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee5.setZIP("68321");
    	         ^
EmployeeDirectorySystem.java:166: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee6.setZIP("68588");
    	         ^
EmployeeDirectorySystem.java:177: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee7.setZIP("68701");
    	         ^
EmployeeDirectorySystem.java:188: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee8.setZIP("80104");
    	         ^
EmployeeDirectorySystem.java:199: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee9.setZIP("80237");
    	         ^
EmployeeDirectorySystem.java:210: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee10.setZIP("68521");
    	          ^
EmployeeDirectorySystem.java:221: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee11.setZIP("68520");
    	          ^
EmployeeDirectorySystem.java:232: cannot find symbol
symbol  : method setZIP(java.lang.String)
location: class FullTimeEmployee
    	employee12.setZIP("68527");
    	          ^
12 errors

Oh never mind I'm an idiot, setZIP is the method called in EmployeeDirectorySystem but setZip is the method I coded in FullTimeEmployee. When flipping back and forth the difference of two capital letters was hard to see. I knew it had to be simple...

Well I'll try and figure out the complicated stuff on my own so thanks for your help, as long as I make no more idiotic mistakes I should be fine.

Now how to close thread...

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.