You are on page 1of 3

import java.io.*; import java.util.*; //import java.lang.String.

*; interface person { String emp_name= "huhu"; float basic= 70000; float HRA=1000; float DA=2000; float tot=100000; } /*abstract class Person { abstract void read() throws IOException; }*/ class custException extends Exception { public custException() { super(); } public custException( String st) { super(st); } } public class Employee implements person { String emp_name1; float basic1; float HRA1; float DA1; float tot1; public Employee() { emp_name1= "hehe"; basic1= 70000; HRA1=1000; DA1=2000; tot1=100000; } public Employee( String name, float bas, float total) { emp_name1=name; basic1=bas; tot1=total; }

void read() { try { Scanner scan= new Scanner(System.in); System.out.println("\n Enter the name of the Employee emp_name1=scan.next(); System.out.println("\n Enter the basic salary basic1=scan.nextFloat(); if (basic > 50000) { throw new custException(" Balance is exceeding the limit"); } //finally disp(); } catch (custException ex) { System.out.println( ex.getMessage()); } /*System.out.println("\n Enter the HRA HRA=scan.nextFloat(); System.out.println("\n Enter the DA :"); DA=scan.nextFloat();*/ } public void disp(float hr, float da) { //System.out.println(" Name :" + emp_name); tot1=(basic+hr+da); System.out.println(" \n Total salary :" + tot); } public void disp() { //System.out.println(" Name :" + emp_name); //tot=(basic+hr+da); System.out.println(" \n Name :" + emp_name); System.out.println(" \n basic :" + basic); System.out.println(" \n HRA :" + HRA); System.out.println(" \n DA :" + DA); System.out.println(" \n Total salary :" + tot); } public static void main(String args[])throws IOException { float h,d; Employee Emp= new Employee(); //Employee Emp= new Employee(); //Manager mg = new Manager(120,100000); //Emp.read(); //mg.reading(); /*Scanner scan= new Scanner(System.in); System.out.println("\n Enter the HRA :");

:"); :");

:");

h=scan.nextFloat(); System.out.println("\n Enter the DA d=scan.nextFloat();*/ //mg.display(); //mg.disp(h,d); Emp.disp(); //Emp.disp(h,d); } }

:");

You might also like