Hey guys taking a java class and i am having trouble trying to get this to work.
need to Creat a class called Employee that includes three instance variabels, a first name (type string), a last name (type string) and a monthly salary (double). provide a constructor that initializes the three instance variables. provide a set and a get method for each instance variable. if the monthly salary is not positive, do not set its value write a test application named EmployeeTest that demonstrates class Employee's capabilities. Creat two employee objects and display each objects yearly salary. Then give each Employee a 10% raise and display each Employee's yearly salary agian.
So that is the problem and so far i have got
class Employee{
// data vector
String fn;
String ln;
double s;
// constructor
public Employee(String f, String l, double sal) {
fn = f;
ln = l;
s = sal;
}
// set procedure
void setFirst(String fNew) {
fn = fNew;
}
void setLast(String lNew) {
ln = lNew;
}
void setSal(double sNew) {
s = sNew;
}
//get function
String getFirst(){
return fn;
}
String getLast(){
return ln;
}
String getSalary(){
return s;
}
}
and for the test i have
public class EmployeeTest {
public static void main(String [] args){
Employee e1 = new Employee();
Employee e2 = new Employee("John","Pimpson",1.00);
System.out.printf("%s\t%s\t%f\n", e2.getFirst(),e2.getLast(),e2.getSalary());
System.out.printf("%s\t%s\t%f\n", e1.getFirst(),e1.getLast(),e1.getSalary());
e1.setFirst("John 5");
e1.setLast("Player");
e1.setSalary(10.00);
System.out.printf("%s\t%s\t%f\n", e1.getFirst(),e1.getLast(),e1.getSalary());
e.raiseSalary(1.1);
}
}
now im just stuck and trying to read threw my book for more info but if someone who knows java could maybe lend me a hand with this i would be greatful since this is only my first week in class.
need to Creat a class called Employee that includes three instance variabels, a first name (type string), a last name (type string) and a monthly salary (double). provide a constructor that initializes the three instance variables. provide a set and a get method for each instance variable. if the monthly salary is not positive, do not set its value write a test application named EmployeeTest that demonstrates class Employee's capabilities. Creat two employee objects and display each objects yearly salary. Then give each Employee a 10% raise and display each Employee's yearly salary agian.
So that is the problem and so far i have got
class Employee{
// data vector
String fn;
String ln;
double s;
// constructor
public Employee(String f, String l, double sal) {
fn = f;
ln = l;
s = sal;
}
// set procedure
void setFirst(String fNew) {
fn = fNew;
}
void setLast(String lNew) {
ln = lNew;
}
void setSal(double sNew) {
s = sNew;
}
//get function
String getFirst(){
return fn;
}
String getLast(){
return ln;
}
String getSalary(){
return s;
}
}
and for the test i have
public class EmployeeTest {
public static void main(String [] args){
Employee e1 = new Employee();
Employee e2 = new Employee("John","Pimpson",1.00);
System.out.printf("%s\t%s\t%f\n", e2.getFirst(),e2.getLast(),e2.getSalary());
System.out.printf("%s\t%s\t%f\n", e1.getFirst(),e1.getLast(),e1.getSalary());
e1.setFirst("John 5");
e1.setLast("Player");
e1.setSalary(10.00);
System.out.printf("%s\t%s\t%f\n", e1.getFirst(),e1.getLast(),e1.getSalary());
e.raiseSalary(1.1);
}
}
now im just stuck and trying to read threw my book for more info but if someone who knows java could maybe lend me a hand with this i would be greatful since this is only my first week in class.