Excersise: 7 Import Package | Java | Tamizhan Goals

Import package

Excersise: 7

    Create and Import Package (Minimum Three Classes)

Program


Package EmppDip
import java.io.*;
import java.lang.*;
class Emp
{
String ename;
int empid;
String category;
double bpay;
double da,hra,ma,ded,loan,pf,gp,np;
Emp(String na,int id,String cate,double pay)
{
ename=na;
empid=id;
category=cate;
bpay=pay;
}
void netpay()
{
da=bpay*0.1;
hra=bpay*0.05;
ma=250.0;
loan=bpay*0.15;
if(bpay<6000)
pf=bpay*0.125;
else
pf=780.0;
ded=loan+pf;
np=bpay-ded;
gp=bpay+da+ma+hra;
}
void display()
{
System.out.println("\t\t Employee pay bill:");
System.out.println("\t\t==================");
System.out.println("Employee name:"+ename);
System.out.println("category:"+category);
System.out.println("basic pay:"+bpay);
System.out.println("da:"+da+"\t\t hra:"+hra+"\t\t ma:"+pf);
System.out.println("loan:"+loan+"\t\tpf:"+pf);
System.out.println("Dedication:"+ded+"\tgrosspay:"+gp);
System.out.println("Netpay:"+np);
}
}
class Empnet
{
public static void main(String arg[])throws IOException
{
DataInputStream din=new DataInputStream(System.in);
System.out.println("\nEnter the employee details");
System.out.println("\n===================");
System.out.println("\nEnter the Employee name:");
String en=din.readLine();
System.out.println("Enter the id number of employee:");
int ed=Integer.parseInt(din.readLine());
System.out.println("Enter the employee category:");
String ca=din.readLine();
System.out.println("Enter the basic pay:");
double bp= Double.parseDouble(din.readLine());
Emp ey= new Emp(en,ed,ca,bp);
ey.netpay();
ey.display();
}
}

Output

Post a Comment

Thanks for your comments. Please be visit and given positive review on our site.

Previous Post Next Post