473,406 Members | 2,217 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

cannot find symbol - method getFirstname()

So I know I need to add a few more lines somewhere to make this work, but I'm not sure how.

[PHP]

// Lab 3: EmployeeTest.java
// Application to test class Employee.

/* Begin class declaration of EmployeeTest class. */
public class EmployeeTest
{
/* Begin main method declaration. */
public static void main (String arg [])
{
/* Create two Employee objects and assign them to Employee variables. */
Employee emp1 = new Employee("Bob", "Jones", 2875);
Employee emp2 = new Employee("Susan", "Baker", 3150.75);

/* Output the first name, last name and salary for each Employee. */
System.out.printf("Employee 1: %s %s; Yearly Salary: %.2f\n", emp1.getFirstname(), emp1.getLastName(), emp1.getEmployeeSalary());
System.out.printf("Employee 2: %s %s; Yearly Salary: %.2f\n", emp2.getFirstname(), emp2.getLastName(), emp2.getEmployeeSalary());

/* Give each Employee a 10% raise. */
double salary1 = emp1.getEmployeeSalary()*1.1;
emp1.setEmployeeSalary(salary1);
double salary2 = emp2.getEmployeeSalary()*1.1;
emp2.setEmployeeSalary(salary2);

/* Output the first name, last name and salary of each Employee again. */
System.out.printf("Employee 1: %s %s; Yearly Salary: %.2f\n", emp1.getFirstname(), emp1.getLastName(), emp1.getEmployeeSalary());
System.out.printf("Employee 2: %s %s; Yearly Salary: %.2f\n", emp2.getFirstname(), emp2.getLastName(), emp2.getEmployeeSalary());

/* End main method declaration */
}
/* End class declaration of EmployeeTest class. */
}

[/PHP]

I have another class in this same project that has somewhat to do with this one.

[PHP]


/**
* Write a description of class Employee here.
*
* @author (your name)
* @version (a version number or a date)
*/
public class Employee
{
// instance variables - replace the example below with your own
private String firstName;
private String lastName;
private double salary;

/**
* Constructor for objects of class Employee
*/
public Employee(String fName, String lName, double Sal)
{
// initialise instance variables
firstName = fName;
lastName = lName;
salary = Sal;
}

/**
* An example of a method - replace this comment with your own
*
* @param y a sample parameter for a method
* @return the sum of x and y
*/
public double getEmployeeSalary()
{
// put your code here
return salary;

}

public void setEmployeeSalary(double sal)
{
// put your code here
if(sal >= 0.0)
salary = sal;
}
}

[/PHP]

The general idea is that the program prints out the names of the employees and then their salary, then gives them a 10% raise and then prints it back out. The problem is that the employeetest class doesn't have the .getFirstname method and I don't know where to put it. Any help would be apreciated.
Feb 5 '08 #1
5 3851
RedSon
5,000 Expert 4TB
So I know I need to add a few more lines somewhere to make this work, but I'm not sure how.

The general idea is that the program prints out the names of the employees and then their salary, then gives them a 10% raise and then prints it back out. The problem is that the employeetest class doesn't have the .getFirstname method and I don't know where to put it. Any help would be apreciated.
What is the type of object that you need to call getFirstname() on? You already have a few methods in this class, how difficult would it be to add a couple more?
Feb 5 '08 #2
r035198x
13,262 8TB
You have two classes that you think are related and don't know how to get them to work together?
In that case reading Sun's Java tutorial isn't a bad thing.
P.S You can download that whole thing to your computer.
Feb 6 '08 #3
JosAH
11,448 Expert 8TB
I find the comment lines 25-30 in your second class very confusing. Did you write
these classes yourself?

kind regards,

Jos
Feb 6 '08 #4
RedSon
5,000 Expert 4TB
I find the comment lines 25-30 in your second class very confusing. Did you write
these classes yourself?

kind regards,

Jos
I think the EmployeeTest class was written by the instructor of the course.
Feb 6 '08 #5
JosAH
11,448 Expert 8TB
I think the EmployeeTest class was written by the instructor of the course.
That might well be but still the following comment in the Employee class:

Expand|Select|Wrap|Line Numbers
  1.  /**
  2.      * An example of a method - replace this comment with your own
  3.      * 
  4.      * @param  y   a sample parameter for a method
  5.      * @return     the sum of x and y 
  6.      */
  7.  
... doesn't make any sense and was/is confusing (at least me).

kind regards,

Jos
Feb 6 '08 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

15
by: Bjorn Jensen | last post by:
Hi! An beginner question: Pleas help me with this (-: Error (the arrow points on the s in sqrt) ===== tal.java:6: cannot find symbol symbol : method sqrt(int) location: class tal...
1
by: vsp15584 | last post by:
Hii..i use the coding as below :- import java.applet.applet; import java.awt.*; import com.sun.j3d.utils.applet.mainframe; import com.sun.j3d.utils.universe.*; import...
1
by: Shiva48 | last post by:
Thanks to Gannon11 and ro351988- Moderator. I give below the complete Java file and pls help me to rectify the errors. package com.wrox.proj2ee.ch10.app; import java.io.*; import...
2
by: cazconv2007 | last post by:
i cant understand why it says cannot find symbol can you guys look thanx i can get it to show john doe but not my next name. class Name { public String firstName ="carl"; private...
1
by: jank | last post by:
hi, I wrote sending mass email program in java. If i try to compile using ant compiler, i am getting this error. c:\mail\src\com\mail\action\SendMail.java:125: cannot find symbol ...
4
by: jingchua | last post by:
Hi, can anyone help out here???? I have the below error after compling the file. Any idea what is wrong in the declaration that was done in the above code??? Appreciate any help on shedding some...
2
by: karinmorena | last post by:
I'm having 4 errors, I'm very new at this and I would appreciate your input. The error I get is: Week5MortgageGUI.java:151:cannot find symbol symbol: method allInterest(double,double,double)...
10
by: CodeNoob | last post by:
please help been working on a project got it down to 5 errors from 100 now i have no idea what to do. Errors: init: deps-jar: Created dir: C:\Users\Tommy\Desktop\build\classes Compiling 306...
7
oll3i
by: oll3i | last post by:
in deploytool when i go to "cmp database" i get the message "cannot find accessor getFirstName for CMP field firstName"?
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.