Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Main.java to edit this template
- */
- package company;
- /**
- *
- * @author urvil
- */
- import java.util.*;
- public class Company extends employee{
- /**
- * @param args the command line arguments
- */
- public static void main(String[] args) {
- int choice;
- String s;
- ArrayList<employee> a1 = new ArrayList<employee>();
- Scanner sc = new Scanner(System.in);
- do
- {
- System.out.println("1.Add");
- System.out.println("2.Display");
- System.out.println("3.Search position");
- System.out.println("4.Search employee");
- System.out.println("5.Search OG");
- System.out.println("6.Exit");
- choice = sc.nextInt();
- sc.nextLine();
- switch(choice){
- case 1:
- employee e = new employee();
- a1.add(e);
- break;
- case 2:
- for(employee e1:a1)
- e1.display();
- break;
- case 3:
- System.out.println("Enter position");
- s=sc.nextLine();
- for(employee e1:a1)
- if(e1.getType().equals(s))
- e1.display();
- break;
- case 4:
- System.out.println("Enter name");
- s=sc.nextLine();
- for(employee e1:a1)
- if(e1.getName().equals(s))
- e1.display();
- break;
- case 5:
- // System.out.println("id\tname\tage\ttype\tsalary");
- // for(employee e1:a1)
- // if(e1.getAge()>30 && e1.getAge()<60)
- // e1.display();
- break;
- default:
- System.out.println("invalid");
- break;
- }
- }while(choice!=6);
- }
- }
- /*
- * Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
- * Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
- */
- package company;
- /**
- *
- * @author urvil
- */
- import java.util.*;
- abstract class variables{
- public String name,type;
- public int id,jy,exp;
- public double salary,bonus,total;
- Calendar calendar = new GregorianCalendar();
- int year = calendar.get(Calendar.YEAR);
- }
- interface functions{
- public abstract String getType();
- public abstract String getName();
- public abstract int getjy();
- public abstract void display();
- }
- public class employee extends variables implements functions {
- Scanner sc = new Scanner(System.in);
- public employee()
- {
- System.out.println("Enter Id");
- id = sc.nextInt();
- sc.nextLine();
- System.out.println("Enter name");
- name = sc.nextLine();
- System.out.println("Enter job position(m,k,c)");
- type = sc.nextLine();
- System.out.println("Enter jy");
- jy = sc.nextInt();
- sc.nextLine();
- System.out.println("Enter salary");
- salary = sc.nextDouble();
- if(type.equals("m"))
- total += salary*0.1;
- else if(type.equals("k"))
- total += salary*0.06;
- else
- total = salary;
- exp = year-jy;
- if(exp>5 && exp<15)
- {
- bonus = 10000;
- total+=bonus;
- }
- else if(exp>15 && exp<25)
- {
- bonus = 20000;
- total+=bonus;
- }
- else if(exp>25 && exp<35)
- {
- bonus = 30000;
- total+=bonus;
- }
- else
- {
- bonus = 40000;
- total+=bonus;
- }
- }
- @Override
- public String getType() {
- return type;
- }
- @Override
- public String getName() {
- return name;
- }
- @Override
- public void display() {
- System.out.println("id: "+id+"\n"
- +"name: "+name+"\n"
- +"jy: "+jy+"\n"
- +"type: "+type+"\n"
- +"salary: "+salary
- +"\n"+"exp: "+exp+"\n"
- +"total: "+total+
- "\n"+"bonus: "+bonus);
- }
- @Override
- public int getjy() {
- return jy;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement