Untitled
unknown
plain_text
18 days ago
2.0 kB
5
Indexable
Never
import java.util.Scanner; class employee { Scanner scan = new Scanner(System.in); int age,phone,salary; String name,address; public void details() { System.out.println("Enter the name"); name = scan.nextLine(); System.out.println("Enter the address"); address = scan.nextLine(); System.out.println("Enter the age"); age = scan.nextInt(); System.out.println("Enter the phone number"); phone = scan.nextInt(); System.out.println("Enter the salary"); salary = scan.nextInt(); } public void Print_Salary() { System.out.println("Salary is : "+salary); } } class officer extends employee { Scanner scan = new Scanner(System.in); String spec; public void offi_details() { System.out.println("Enter the specialization"); spec = scan.nextLine(); } public void offi() { System.out.println("Specialization :"+spec); } } class manager extends employee { Scanner scan = new Scanner(System.in); String dep; public void mang_details() { System.out.println("Enter the department"); dep = scan.nextLine(); } public void mang() { System.out.println("department is : "+dep); } } public class employee_details { public static void main(String s[]) { officer o = new officer(); manager m = new manager(); m.details(); m.mang_details(); System.out.println("Name :"+m.name+"\nAddress :"+m.address+"\nphone number :"+m.phone+"\nAge :"+m.age); m.mang(); m.Print_Salary(); System.out.println("\n\n"); o.details(); o.offi_details(); System.out.println("Name :"+o.name+"\nAddress :"+o.address+"\nphone number :"+o.phone+"\nAge :"+o.age); o.offi(); o.Print_Salary(); } }
Leave a Comment