Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentDB_ArrayOfObjects.java
More file actions
Latest commit
53 lines (48 loc) · 1.23 KB
/
Copy pathStudentDB_ArrayOfObjects.java
File metadata and controls
53 lines (48 loc) · 1.23 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
importjava.util.*;
/// Program which collects and prints details of 'n' number of students
classStudent
{
Stringname;
intp,c,m,rno;
voidacceptDetails()
{
Scannerscan = newScanner(System.in);
System.out.println("Enter name of Student : ");
name=scan.nextLine();
System.out.println("Specify Roll No : ");
rno=scan.nextInt();
System.out.println("Specify PCM Marks (one-by-one)\n");
p=scan.nextInt();
c=scan.nextInt();
m=scan.nextInt();
System.out.println("Details for student " + name + " Recorded successfully");
}
voidprintDetails()
{
System.out.println("\nName : " + name);
System.out.println("Roll No : " + rno);
System.out.println("Physics : " + p);
System.out.println("Chemistry : " + c);
System.out.println("Maths : " + m);
System.out.println("\n");
}
}
classStudentDemo
{
publicstaticvoidmain(Stringargs[])
{
inti;
Student[] s = newStudent[10];
System.out.println("\n[!] Specify the number of Students\n");
Scannersc = newScanner(System.in);
intno = sc.nextInt();
for(i=0;i<no;i++)
{
s[i] = newStudent();
s[i].acceptDetails();
}
System.out.println("\n\n[!] Printing Student Database\n\n");
for(i=0;i<no;i++)
s[i].printDetails();
}
}