-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMain.java
65 lines (64 loc) · 2.22 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
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
while(true){
Scanner sc = new Scanner(System.in);
System.out.println("1. Add Student");
System.out.println("2. View Students");
System.out.println("3. Search Student");
System.out.println("4. Calculate Average Marks");
System.out.println("5. Exit");;
System.out.print("Enter your choice ");
int choice = sc.nextInt();
sc.nextLine();
switch(choice){
case 1: System.out.print("Enter your name: ");
String name= sc.nextLine();
System.out.print("Enter your roll number: ");
int rollNo= sc.nextInt();
System.out.print("Enter your age : ");
int age= sc.nextInt();
System.out.print("Enter your marks: ");
int marks= sc.nextInt();
Student std= new Student(name,age,rollNo,marks);
if(Database.map.containsKey(rollNo)){
System.out.println("Roll No. is already assigned");
}
if(marks<0){
System.out.println("Marks cannot be negative");
}
else{
Database.addingStudent(rollNo, std);
System.out.println("Student added successfuly");
}
break;
case 2: if(Database.map.size()==0){
System.out.println("No Data of Student present");
}
else{
for(Student i:Database.map.values()){
System.out.println("List of Students");
i.view();
}
}
break;
case 3:System.out.print("Enter your roll number: ");
int roll= sc.nextInt();
Student data=Database.map.get(roll);
if(data!=null){
data.view();
}else{
System.out.println("Student not found");
}
System.out.println("******");
break;
case 4: Database.calculatemarks();
break;
case 5: sc.close();
System.exit(0);
break;
default: System.out.println("Invalid Input");
}
}
}
}