-
Notifications
You must be signed in to change notification settings - Fork 0
/
MultilevelUni.java
75 lines (74 loc) · 1.71 KB
/
MultilevelUni.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
//Multilevel Inheritance-University
import java.util.*;
class University
{
Scanner sc=new Scanner (System.in);
String uname,ulocation,uacc;
void read1()
{
System.out.println("Enter university name ");
uname=sc.nextLine();
System.out.println("Enter university location ");
ulocation=sc.nextLine();
System.out.println("Enter university date of accreditation ");
uacc=sc.nextLine();
}
void display1()
{
System.out.println("University name is "+uname);
System.out.println("University location is "+ulocation);
System.out.println("University date of accreditation is "+uacc);
}
}
class College extends University
{
String cname,clocation,cacc;
void read2()
{
System.out.println("Enter college name ");
cname=sc.nextLine();
System.out.println("Enter college location ");
clocation=sc.nextLine();
System.out.println("Enter college date of accreditation ");
cacc=sc.nextLine();
}
void display2()
{
System.out.println("College name is "+cname);
System.out.println("College location is "+clocation);
System.out.println("College date of accreditation is "+cacc);
}
}
class Course extends College
{
String course_name, duration;
double fees;
void read3()
{
System.out.println("Enter course name ");
course_name=sc.nextLine();
System.out.println("Enter course duration ");
duration=sc.next();
System.out.println("Enter course fee ");
fees=sc.nextDouble();
}
void display3()
{
System.out.println("Course name is "+course_name);
System.out.println("Course fee is "+fees);
System.out.println("Course duration is "+duration);
}
}
class MultilevelUni
{
public static void main(String args[])
{
Course c = new Course();
c.read1();
c.read2();
c.read3();
c.display1();
c.display2();
c.display3();
}
}