Skip to content

Instantly share code, notes, and snippets.

@mamiwinsfall93
Created January 18, 2020 17:16
Show Gist options
  • Save mamiwinsfall93/cba030e6f59b81b85b095dac63078d91 to your computer and use it in GitHub Desktop.
Save mamiwinsfall93/cba030e6f59b81b85b095dac63078d91 to your computer and use it in GitHub Desktop.
Employee, classes with salary information
/** Filename: Employee.java
* Author: Ndatta Fall
*
* Purpose: Employee, classes with salary information
*
*/
public class Employee {
private String name;//to store name of employee
private int monthlySalary;//to store monthly salary
public Employee(String name, int monthlySalary) {// constructor that allows the name and montly to be initialized
this.name = name;
this.monthlySalary = monthlySalary;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getMonthlySalary() {
return monthlySalary;
}
public void setMonthlySalary(int monthlySalary) {
this.monthlySalary = monthlySalary;
}
public int AnnualSalary() {// method named annual salary that returns the salary for a whole year
int annualPay = 12 * monthlySalary;
return annualPay;
}
public String toString() {// returns employee's information
String employeeInfo = "employee's name: " + getName()
+ "\n" + "Monthly salary : " + getMonthlySalary()
+ "\n" + "Annual salary : " + AnnualSalary();
return employeeInfo;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment