class A { String name,location,address; char gender; } class B extends A { String id; } class Faculty extends B { float salary; Faculty() { Scanner s=new Scanner(System.in); System.out.println("Enter name : "); name=s.next(); System.out.println("Enter location :"); location=s.next(); System.out.println("Enter address : "); address=s.next(); System.out.println("Enter gender :"); gender=s.next().charAt(0); System.out.println("Enter id : "); id=s.next(); System.out.println("Enter Salary : "); salary=s.nextFloat(); } void facultyDetails() { System.out.println("Name of the Faculty is : "+name); System.out.println("location of the Faculty is : "+location); System.out.println("Address of the Faculty is: "+address); System.out.println("Gender of the Faculty is : "+gender); System.out.println("Faculty id is : "+id); System.out.println("Faculty Salary is : "+salary); } } public class Main { public static void main(String args[]) { Faculty F=new Faculty(); F.facultyDetails(); } }
Enter name : Sateesh
Enter location : Delhi
Enter address : Delhi
Enter gender : m
Enter id : 23
Enter Salary : 20000
Name of the Faculty is : Sateesh
location of the Faculty is : Delhi
Address of the Faculty is : Delhi
Gender of the Faculty is : m
Faculty id is : 24
Faculty Salary is : 24000.0