Sem 5‎ > ‎JAVA LAB‎ > ‎

P5: WAP to increment the employee salaries on the basis of designation.

posted Aug 22, 2012, 10:25 AM by Neil Mathew   [ updated Aug 22, 2012, 10:26 AM ]

SOURCE CODE:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
class SmallerEmp
{      
int id,sal;
String name,desg;
 
        void getdata(String p,int q,String r, int s)
        {
        name=p;
        id=q;
        desg=r;
        sal=s;
 
        System.out.println("\n Name: "+name);
        System.out.println(" Id: "+id);
        System.out.println(" Desgignation: "+desg);
        System.out.println(" Salary: "+sal);
        }
}
 
class EmpIncrement extends SmallerEmp
{
 
        void inc_sal()
        {
        if (desg.compareTo("Manager") == 0) {
        sal+=5000;
        System.out.println("\n Incremented Salary :"+sal);
        } if (desg.compareTo("General Manager") == 0 ) {
        sal+=10000;
        System.out.println("\n Incremented Salary :"+sal);
        } if ( desg.compareTo("CEO") == 0) {
        sal+=20000;
        System.out.println("\n Incremented Salary :"+sal);
        } if ( desg.compareTo("Worker") == 0 ) {
        sal+=2000;
        System.out.println("\n Incremented Salary :"+sal);
        }
        }
 
        public static void main(String arg[])
        {
        EmpIncrement e1=new EmpIncrement ();
        String p=arg[0];
        int q=Integer.parseInt(arg[1]);
        String r=arg[2];
        int s=Integer.parseInt(arg[3]);
 
        e1.getdata(p,q,r,s);
        e1.inc_sal();
        }
} 
 



OUTPUT:


C:\Java 1.6\jdk1.6.0_30\bin>javac EmpIncrement.java

 

C:\Java 1.6\jdk1.6.0_30\bin>java EmpIncrement Neil 3305 CEO 20000

 

 Name: Neil

 Id: 3305

 Desgignation: CEO

 Salary: 20000

 

 Incremented Salary :40000

 

C:\Java 1.6\jdk1.6.0_30\bin>java EmpIncrement Jimmy 3323 Worker 10000

 

 Name: Jimmy

 Id: 3323

 Desgignation: Worker

 Salary: 10000

 

 Incremented Salary :12000

 

 


Comments