Java Practical 8
/*Calculate net salary of Employee with following Constraints by overloading salary(). i.If Employee is Manager, pass Basic,DA,HRA,MA,PF,IT,PT. ii.If Employee is Executive, pass Basic,DA,HRA,PF,IT. iii.If Employee is Jr.Executive, pass Basic,DA,HRA,IT. iv.If Employee is Peon,pass Basic,DA.*/
import java.io.*;public class salary_slip
{
void salary(int x,int y)
{
System.out.println("Salary of Peon is "+(x+y));
}
void salary(int x,int y,int z)
{
int gs,it,pt,td;
gs=x+y+z;
it=(gs*10)/100;
if(gs<=5999)
pt=0;
else if(gs>=6000 && gs<=8999)
pt=80;
else if(gs>=9000 && gs<12000)
pt=150;
else if(gs>12000)
pt=200;
else
pt=00;
td=it+pt;
System.out.println("Salary of a Jr.Executive is "+(gs-td));
}
void salary(int x,int y,int z,int a)
{
int gs,it,pt,td;
gs=x+y+z;
it=(gs*10)/100;
if(gs<=5999)
pt=0;
else if(gs>=6000 && gs<=8999)
pt=80;
else if(gs>=9000 && gs<12000)
pt=150;
else if(gs>12000)
pt=200;
else
pt=00;
td=it+pt+a;
System.out.println("Salary of an Executive is "+(gs-td));
}
void salary(int x,int y,int z,int a,int b)
{
int gs,it,pt,td;
gs=x+y+z+b;
it=(gs*10)/100;
if(gs<=5999)
pt=0;
else if(gs>=6000 && gs<=8999)
pt=80;
else if(gs>=9000 && gs<12000)
pt=150;
else if(gs>12000)
pt=200;
else
pt=00;
td=it+pt+a;
System.out.println("Salary of a Manager is "+(gs-td));
}
public static void main(String Args[]) throws IOException
{
int bs,d,hr,ma,pf,c;
DataInputStream in=new DataInputStream(System.in);
System.out.println("1.Manager\n2.Executive\n3.Jr.Executive\n4.Peon");
System.out.print("Enter Employee Type:");
c=Integer.parseInt(in.readLine());
switch(c)
{
case 1:System.out.print("Enter Basic Salary: ");
bs=Integer.parseInt(in.readLine());
System.out.print("Enter DA: ");
d=Integer.parseInt(in.readLine());
System.out.print("Enter HRA: ");
hr=Integer.parseInt(in.readLine());
System.out.print("Enter MA: ");
ma=Integer.parseInt(in.readLine());
System.out.print("Enter PF: ");
pf=Integer.parseInt(in.readLine());
salary(bs,d,hr,pf,ma);
break;
case 2:System.out.print("Enter Basic Salary: ");
bs=Integer.parseInt(in.readLine());
System.out.print("Enter DA: ");
d=Integer.parseInt(in.readLine());
System.out.print("Enter HRA: ");
hr=Integer.parseInt(in.readLine());
System.out.print("Enter PF: ");
pf=Integer.parseInt(in.readLine());
salary(bs,d,hr,pf);
break;
case 3:System.out.print("Enter Basic Salary: ");
bs=Integer.parseInt(in.readLine());
System.out.print("Enter DA: ");
d=Integer.parseInt(in.readLine());
System.out.print("Enter HRA: ");
hr=Integer.parseInt(in.readLine());
salary(bs,d,hr);
break;
case 4:System.out.print("Enter Basic Salary: ");
bs=Integer.parseInt(in.readLine());
System.out.print("Enter DA: ");
d=Integer.parseInt(in.readLine());
salary(bs,d);
break;
default:System.out.print("Thank You!");
}
}
}
Comments
Post a Comment