-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAddStudent.java
More file actions
26 lines (24 loc) · 847 Bytes
/
AddStudent.java
File metadata and controls
26 lines (24 loc) · 847 Bytes
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
package com.tyss.finalassessment;
import java.util.ArrayList;
import java.util.Scanner;
public class AddStudent {
public void addStudent(ArrayList<StudentDetails> list,Scanner scanner)throws Exception {
System.out.println("enter the id of the student");
int id=scanner.nextInt();
for (StudentDetails studentDetails : list) {
if(studentDetails.id==id) {
System.out.println("This id is already exist");
return ;
}
}
System.out.println("enter the name of the student");
String name=scanner.next();
System.out.println("enter the mark of the student");
float mark=scanner.nextFloat();
System.out.println("enter the course of the student");
String course=scanner.next();
StudentDetails details = new StudentDetails(id, name, mark, course);
list.add(details);
System.out.println("Student detail added\n");
}
}