diff --git a/OOP/Java/Lab/Week6/Student/StudentProgram.java b/OOP/Java/Lab/Week6/Student/StudentProgram.java new file mode 100644 index 0000000..23558d6 --- /dev/null +++ b/OOP/Java/Lab/Week6/Student/StudentProgram.java @@ -0,0 +1,66 @@ +class Student { + + int regNo; + String name; + int age; + + public Student(int regNo, String name, int age) { + this.regNo = regNo; + this.name = name; + this.age = age; + } + + public void displayDetails() { + System.out.println( + "Reg No: " + regNo + ", Name: " + name + ", Age: " + age + ); + } +} + +class UG extends Student { + + int semester; + double fees; + + public UG(int regNo, String name, int age, int semester, double fees) { + super(regNo, name, age); + this.semester = semester; + this.fees = fees; + } + + public void displayDetails() { + super.displayDetails(); + System.out.println("Semester: " + semester + ", Fees: " + fees); + } +} + +class PG extends Student { + + int semester; + double fees; + + public PG(int regNo, String name, int age, int semester, double fees) { + super(regNo, name, age); + this.semester = semester; + this.fees = fees; + } + + public void displayDetails() { + super.displayDetails(); + System.out.println("Semester: " + semester + ", Fees: " + fees); + } +} + +public class StudentProgram { + + public static void main(String[] args) { + UG ugStudent = new UG(230901010, "Saarthak Singhal", 20, 3, 500000.0); + PG pgStudent = new PG(230920020, "Aarav Chirag Shah", 25, 2, 350000.0); + + System.out.println("UG Student Details:"); + ugStudent.displayDetails(); + + System.out.println("\nPG Student Details:"); + pgStudent.displayDetails(); + } +}