import java.util.*; class A { String name,location,address; char gender; } class Student extends A { String id; float marks,fee; Student() { 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 marks : "); marks=s.nextFloat(); System.out.println("Enter fee : "); fee=s.nextFloat(); } void studentDetails() { System.out.println("Name of the student is :"+name); System.out.println("location of the student is : "+location); System.out.println("Address of the student is : "+address); System.out.println("Gender of the student is : "+gender); System.out.println("Student id is : "+id); System.out.println("Marks of the student is : "+marks); System.out.println("Student Fee is : "+fee); } } class Faculty extends A { float salary; String id; 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 : Hyd
Enter address : kukatpally
Enter gender : M
Enter id : 1224
Enter marks : 98
Enter fee : 1000
Name of the student is : sateesh
location of the student is : Hyd
Address of the student is : kukatpally
Gender of the student is : M
Student id is : 1224
Marks of the student is : 98.0
Student Fee is : 1000.0
Enter name : Varshini
Enter location : Chennai
Enter address : Chennai
Enter gender : F
Enter id : 23
Enter Salary : 20000
Name of the Faculty is : Varshini
location of the Faculty is : Chennai
Address of the Faculty is : Chennai
Gender of the Faculty is : f
Faculty id is : 24
Faculty Salary is : 24000.0