0% found this document useful (0 votes)
7 views1 page

PGM 3

Uploaded by

sailahari118
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
7 views1 page

PGM 3

Uploaded by

sailahari118
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

package src;

public class Employee {

private String firstName;


private String lastName;
private double monthlySalary;
public Employee(String fname,String lname,double msalary)
{
firstName =fname;
lastName =lname;
monthlySalary =msalary;
}
public void setFirstName (String fname)
{
firstName =fname;
}
public String getFirstName()
{
return firstName;
}
public void setlastName (String lname)
{
lastName= lname;
}
public String getLastName()
{
return lastName;
}
public double getMonthlySalary()
{
return monthlySalary;
}
public double getraiseSalary()
{
double raise = monthlySalary *0.1;
double raiseSalary = (monthlySalary + raise);
return raiseSalary;
}

public static void main(String[] args)


{
Employee emp1 = new Employee ("John","Smith",5000.00 );
Employee emp2 = new Employee ("Jane","Doe",8000.00 );
System.out.printf("Yearly salary of %s %s:%.2f\n",
emp1.getFirstName(),emp1.getLastName(),emp1.getMonthlySalary());
System.out.printf("Yearly Salary of %s %s:%.2f\n",
emp2.getFirstName(),emp2.getLastName(),emp2.getMonthlySalary());
System.out.println();
System.out.println("****Giving 10% raise for each employee****");
System.out.printf("Yearly salary of %s %s:%.2f\
n",emp1.getFirstName(),emp1.getLastName(),emp1.getraiseSalary());
System.out.printf("yearly salary of %s %s:%.2f\
n",emp2.getFirstName(),emp2.getLastName(),emp2.getraiseSalary());
}
}

You might also like