






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
Prepare for your exams
Study with the several resources on Docsity
Earn points to download
Earn points by helping other students or get them with a premium plan
Java lab exercises that include the codes for java classes ,construtor,operator overloading and basics
Typology: Assignments
1 / 10
This page cannot be seen from the preview
Don't miss anything!







import java.util.*; // Publisher class class employee { int emp_id; String name,designation; employee(int p,String d, String e) { emp_id=p; name =d; designation=e; } void display()
System.out.print(emp_id+"\t"); System.out.print(name+"\t"); System.out.print(designation+"\t"); System.out.println(); } } // Inherited permanent class class permanent extends employee { double bp,gp,np; permanent(int p,String d ,String e ,double a) { super(p,d,e); bp=a; gp=bp+ (bp15)/100 +8000+ (((bp15)/100)5)/100; np=gp-(2gp)/100-1250; } void display() { System.out.println("LIST OF ALL permanent employee"); System.out.print(bp+"\t"); System.out.print(gp+"\t"); System.out.print(np+"\t"); super.display(); } } // Inherited temporary class class temporary extends employee { double salary_per_hour,total_hours,total_salary;
public static void main(String[] args) { permanent pe[]=new permanent[5]; for(int i=0;i<3;i++) { Scanner s= new Scanner(System.in); System.out.println("Enter employee id :"); int p=s.nextInt(); System.out.println("Enter employee name :"); String d=s.next(); System.out.println("Enter designation of employee :"); String e=s.next(); System.out.println("Enter Basic pay :"); double a=s.nextDouble(); pe[i]=new permanent(p,d,e,a); } for(int i=0;i<3;i++) { pe[i].display(); } temporary te[]=new temporary[5]; for(int i=0;i<3;i++) { Scanner s= new Scanner(System.in); System.out.println("Enter employee id :"); int p=s.nextInt(); System.out.println("Enter employee name :"); String d=s.next();
System.out.println("Enter designation of employee :"); String e=s.next(); System.out.println("Enter salary per hour :"); double q=s.nextDouble(); System.out.println("Enter total number of hours :"); double r=s.nextDouble(); te[i]=new temporary(p,d,e,q,r); } for(int i=0;i<3;i++) { te[i].display(); } search(pe,3,"Arun"); } }