package sateesh; import java.util.*; class A { String name,location,address; char gender; } public class Student extends A { String id; float marks,fee; public 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(); } public 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); } }Note: Do not run the package Program
import sateesh.Student; class Demo { public static void main(String args[]) { Student s=new Student(); s.studentDetails(); } }
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