-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentDB_ArrayOfObjects.java
More file actions
53 lines (48 loc) · 1.23 KB
/
StudentDB_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
import java.util.*;
/// Program which collects and prints details of 'n' number of students
class Student
{
String name;
int p,c,m,rno;
void acceptDetails()
{
Scanner scan = new Scanner(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");
}
void printDetails()
{
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");
}
}
class StudentDemo
{
public static void main(String args[])
{
int i;
Student[] s = new Student[10];
System.out.println("\n[!] Specify the number of Students\n");
Scanner sc = new Scanner(System.in);
int no = sc.nextInt();
for(i=0;i<no;i++)
{
s[i] = new Student();
s[i].acceptDetails();
}
System.out.println("\n\n[!] Printing Student Database\n\n");
for(i=0;i<no;i++)
s[i].printDetails();
}
}