forked from ronijpandey/Java-Codes
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathUniversity.java
More file actions
251 lines (168 loc) · 4.63 KB
/
University.java
File metadata and controls
251 lines (168 loc) · 4.63 KB
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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
package javacodes;
import java.util.*;
class Students
{
String name="";
int roll=0;
double cgpa=0.0;
Students(String name,int roll,double cgpa)
{
this.name=name;
this.roll=roll;
this.cgpa=cgpa;
}
Students(){}
void setstu(String name,int roll,double cgpa)
{
this.name=name;
this.roll=roll;
this.cgpa=cgpa;
}
void getstu()
{
System.out.println(name+"\t"+roll+"\t"+cgpa);
}
}
class Sem
{
ArrayList<Students> li;
void setsem()
{
Scanner in=new Scanner(System.in);
System.out.print("Enter number of Students in this Sem :");
int n=in.nextInt();
li=new ArrayList<Students>(n);
String name;int roll;double cgpa;
Students obj;
for(int i=0;i<n;++i)
{
obj=new Students();
System.out.println("Student "+(i+1)+" :");
System.out.print("Enter name :");
name=in.next();
System.out.print("Enter roll :");
roll=in.nextInt();
System.out.print("Enter cgpa :");
cgpa=in.nextDouble();
obj.setstu(name, roll, cgpa);
li.add(obj);
}
}
void showsem()
{
System.out.println("Name\tRoll\tCGPA");
for(Students i:li)
{
i.getstu();
}
}
}
class Course
{
String name;
ArrayList<Sem> li;
void setcourse()
{
Scanner in=new Scanner(System.in);
System.out.println("Enter name of this Course :");
name=in.next();
System.out.print("Enter number of Sem in this Course :");
int n=in.nextInt();
li=new ArrayList<Sem>(n);
Sem obj;
for(int i=0;i<n;i++)
{
obj=new Sem();
System.out.println("\tSemester "+(i+1)+" :");
obj.setsem();
li.add(obj);
}
}
void showcourse()
{
int c=1;
System.out.println(name);
for(Sem i:li)
{
System.out.println("\tSemester "+c);
i.showsem();
c++;
}
}
}
class Department
{
String name;
ArrayList<Course> li;
void setdept()
{
Scanner in=new Scanner(System.in);
System.out.println("Enter name of this Department :");
name=in.nextLine();
System.out.print("Enter number of Courses in this Department :");
int n=in.nextInt();
li=new ArrayList<Course>(n);
Course obj;
for(int i=0;i<n;i++)
{
obj=new Course();
System.out.println("\tCourse "+(i+1)+" :");
obj.setcourse();
li.add(obj);
}
}
void showdept()
{
int c=1;
System.out.println(name);
for(Course i:li)
{
System.out.print("\tCourse "+c+" :");
i.showcourse();
c++;
}
}
}
class Institute
{
String name;
ArrayList<Department> li;
void setinst()
{
Scanner in=new Scanner(System.in);
System.out.println("Enter name of this Institute :");
name=in.next();
System.out.print("Enter number of Departments in this Institute :");
int n=in.nextInt();
li=new ArrayList<Department>(n);
Department obj;
for(int i=0;i<n;i++)
{
obj=new Department();
System.out.println("\tDepartment "+(i+1)+" :");
obj.setdept();
li.add(obj);
}
}
void showinst()
{
int c=1;
System.out.println(name);
for(Department i:li)
{
System.out.print("\tDepartment "+c+" :");
i.showdept();
c++;
}
}
}
public class University {
public static void main(String[] args)
{
Scanner in=new Scanner(System.in);
System.out.println("Welcome!");
Institute obj=new Institute();
obj.setinst();
obj.showinst();
}
}