Last active
November 12, 2015 16:12
-
-
Save iamneaz/a57e309967c33d6d8ec4 to your computer and use it in GitHub Desktop.
Employee Record System
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class CommissionEmployee extends Employee{ | |
| public double persentage; | |
| public double totalSale; | |
| private double salary; | |
| public CommissionEmployee(String name,double persentage,double totalSale,int type) { | |
| super(name,type); | |
| this.persentage=persentage; | |
| this.totalSale=totalSale; | |
| // TODO Auto-generated constructor stub | |
| } | |
| @Override | |
| public double getSalary() { | |
| // TODO Auto-generated method stub | |
| return this.salary; | |
| } | |
| @Override | |
| public double setSalary() { | |
| // TODO Auto-generated method stub | |
| return this.salary=this.salary+(this.totalSale+((this.persentage*this.totalSale)/100)); | |
| } | |
| @Override | |
| public double increasedSalary(double percent) { | |
| // TODO Auto-generated method stub | |
| return this.salary; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public abstract class Employee { | |
| public String name; | |
| public double salary; | |
| public int type; | |
| public Employee(String name,int type) | |
| { | |
| this.name=name; | |
| this.type=type; | |
| } | |
| public abstract double getSalary(); | |
| public abstract double setSalary(); | |
| public abstract double increasedSalary(double percent); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class HourlyEmployee extends Employee{ | |
| public double hours; | |
| public double hourlyRate; | |
| private double salary; | |
| public HourlyEmployee(String name,double hours,double hourlyRate,int type) { | |
| super(name,type); | |
| this.hours=hours; | |
| this.hourlyRate=hourlyRate; | |
| // TODO Auto-generated constructor stub | |
| } | |
| @Override | |
| public double getSalary() { | |
| // TODO Auto-generated method stub | |
| return this.salary; | |
| } | |
| @Override | |
| public double setSalary() { | |
| // TODO Auto-generated method stub | |
| return this.salary=this.salary+ this.hours*this.hourlyRate; | |
| } | |
| @Override | |
| public double increasedSalary(double percent) { | |
| // TODO Auto-generated method stub | |
| return this.salary; | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import java.util.*; | |
| public class main { | |
| public static void main(String[] args) { | |
| // TODO Auto-generated method stub | |
| Scanner input= new Scanner(System.in); | |
| System.out.println("How many Employees ?"); | |
| int n=input.nextInt(); | |
| Employee[] employees = new Employee[n]; | |
| for(int i=0;i<n;i++) | |
| { | |
| int j=i+1; | |
| System.out.println("Enter the name of ["+j+"] Employee :"); | |
| String name = input.next() ; | |
| System.out.println("Which type of Employee?\npress[1] for Salaries\npress[2] for hourly\npress[3] for commission"); | |
| int type = input.nextInt(); | |
| if(type==1) | |
| { | |
| System.out.println("weeks worked : "); | |
| double weeksW=input.nextDouble(); | |
| System.out.println("week rate"); | |
| double weekRate=input.nextDouble(); | |
| employees[i] = new SalariedEmployee(name,weeksW,weekRate,1); | |
| employees[i].setSalary(); | |
| } | |
| else if(type==2) | |
| { | |
| System.out.println("hours worked : "); | |
| double hoursW=input.nextDouble(); | |
| System.out.println("hour rate: "); | |
| double hourRate=input.nextDouble(); | |
| employees[i] = new HourlyEmployee(name,hoursW,hourRate,2); | |
| employees[i].setSalary(); | |
| } | |
| else if(type ==3) | |
| { | |
| System.out.println("persentage : "); | |
| double persentage=input.nextDouble(); | |
| System.out.println("total sold: "); | |
| double totalSold=input.nextDouble(); | |
| employees[i] = new HourlyEmployee(name,persentage,totalSold,3); | |
| employees[i].setSalary(); | |
| } | |
| } | |
| while(true) | |
| { | |
| System.out.println("1.increase\n2.salary & description\n3.know type"); | |
| int infut=input.nextInt(); | |
| if(infut==1) | |
| { | |
| System.out.println("How many percent to increase ?"); | |
| double increment=input.nextDouble(); | |
| for(int i=0;i<n;i++) | |
| { | |
| employees[i].increasedSalary(increment); | |
| } | |
| } | |
| else if(infut==2) | |
| { | |
| for(int i=0;i<n;i++) | |
| { | |
| int j=i+1; | |
| System.out.println("Name of employee["+j+"]:"+employees[i].name); | |
| System.out.println("Salary :"+employees[i].getSalary()); | |
| } | |
| } | |
| else if(infut==3) | |
| { | |
| System.out.println("Which type of employees information you want to know ?\npress[1] for Salaries\npress[2] for hourly\npress[3] for commission"); | |
| int type = input.nextInt(); | |
| if(type==1) | |
| { | |
| for(int i=0;i<n;i++) | |
| { | |
| if(employees[i].type==1) | |
| { | |
| System.out.println("Name of employee:"+employees[i].name); | |
| System.out.println("Salary :"+employees[i].getSalary()); | |
| } | |
| } | |
| } | |
| else if(type==2) | |
| { | |
| for(int i=0;i<n;i++) | |
| { | |
| if(employees[i].type==2) | |
| { | |
| System.out.println("Name of employee:"+employees[i].name); | |
| System.out.println("Salary :"+employees[i].getSalary()); | |
| } | |
| } | |
| } | |
| else if(type==3) | |
| { | |
| for(int i=0;i<n;i++) | |
| { | |
| if(employees[i].type==3) | |
| { | |
| System.out.println("Name of employee:"+employees[i].name); | |
| System.out.println("Salary :"+employees[i].getSalary()); | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| public class SalariedEmployee extends Employee{ | |
| public double weeks; | |
| public double weeklyRate; | |
| private double salary; | |
| public SalariedEmployee(String name,double weeks,double weeklyRate,int type) { | |
| super(name,type); | |
| this.weeks=weeks; | |
| this.weeklyRate=weeklyRate; | |
| // TODO Auto-generated constructor stub | |
| } | |
| @Override | |
| public double getSalary() { | |
| // TODO Auto-generated method stub | |
| return this.salary; | |
| } | |
| @Override | |
| public double setSalary() { | |
| // TODO Auto-generated method stub | |
| return this.salary = this.salary+weeks*weeklyRate; | |
| } | |
| @Override | |
| public double increasedSalary(double percent) { | |
| // TODO Auto-generated method stub | |
| this.salary=this.salary+(percent*this.salary)/100; | |
| return this.salary; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment