forked from vaibhavjoon/Hacktoberfest-BMU-ACM-2021
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Main.java
149 lines (142 loc) · 5.15 KB
/
Main.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
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
package com.company;
import java.util.*;
import java.awt.*;
import java.util.Scanner;
class OOP {
public interface Department{
public void getDetpName();
public void getDetpHead();
}
public static class Hostel{
protected String hname,hlocation;
int noofroom;
void getHostelName(){
System.out.println("Name Of the Hostel : " + hname);
}
void getHostelLocation(){
System.out.println("Hostel Location : " + hlocation);
}
void getNoOfRoom(){
System.out.println("Total Room : " + noofroom);
}
}
static class Student extends Hostel implements Department
{
String sname,regno,elesub;
String deptName,deptHead;
int avgMarks;
void getStudentName(){
System.out.println("Student : " + sname);
}
String getStudentRegNo(){
return regno;
}
void getElectiveSubject(){
System.out.println("Elective Subject : " + elesub);
}
void getAvgMarks(){
System.out.println("Average Marks : " + avgMarks);
}
public void getDetpName(){
System.out.println("Department Name : " + deptName);
}
public void getDetpHead(){
System.out.println("Department Head : " + deptHead);
}
void addStudent(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter Student name : ");
sname=sc.nextLine();
System.out.print("Enter Registration Number : ");
regno=sc.nextLine();
System.out.print("Enter Elective Subject : ");
elesub=sc.nextLine();
System.out.print("Enter Hostel Name : ");
hname=sc.nextLine();
System.out.print("Enter Hostel Location : ");
hlocation=sc.nextLine();
System.out.print("Enter Department Name : ");
deptName=sc.nextLine();
System.out.print("Enter Department Head : ");
deptHead=sc.nextLine();
System.out.print("Enter No of room : ");
noofroom=sc.nextInt();
System.out.print("Enter Avg Marks : ");
avgMarks=sc.nextInt();
}
void migrate(){
Scanner sc=new Scanner(System.in);
System.out.print("Enter new Department Name : ");
deptName=sc.nextLine();
System.out.print("Enter new Department Head : ");
deptHead=sc.nextLine();
}
void display(){
getStudentName();
System.out.println(" Student Registration No is : " + getStudentRegNo());
getElectiveSubject();
getAvgMarks();
getDetpName();
getDetpHead();
}
}
class StudentMaster{
public static void main(String []args){
Scanner sc=new Scanner(System.in);
Student []st=new Student[100];
int sno=0;
String rno;
int ch;
boolean b;
while(true){
System.out.println("\n 1. Admit a student");
System.out.println(" 2. Migrate a student");
System.out.println(" 3. Display");
System.out.println(" 4. Exit");
System.out.println(" 5. Enter Your Choice");
ch=sc.nextInt();
switch(ch){
case 1:
st[sno]= new Student();
st[sno++].addStudent();
break;
case 2:
System.out.println("Enter Registration no : ");
rno=sc.next();
b=false;
for(int i=0;i<sno;i++){
if(st[i].getStudentRegNo().equals(rno)){
b=true;
st[0].migrate();
break;
}
}
if(b==false)
{
System.out.println("Student Not Found");
}
break;
case 3:
System.out.println("Enter Registration no : ");
rno=sc.next();
b=false;
for(int i=0;i<sno;i++){
if(st[i].getStudentRegNo().equals(rno)){
b=true;
st[0].display();
break;
}
}
if(b==false){
System.out.println("Student Not Found");
}
break;
case 4:
System.exit(0);
default:
System.out.println("--Invalid Entry--");
}
}
}
}
}