-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathstudents2.java
More file actions
44 lines (32 loc) · 1.24 KB
/
Copy pathstudents2.java
File metadata and controls
44 lines (32 loc) · 1.24 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
import java.util.*;
class students2{
String usn, name, branch;
long phn;
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int n;
System.out.println("enter the no. of students");
n = sc.nextInt();
students2 obj[] = new students2[n];//making the array of type student
int i;
for (i=0; i<n; i++){
obj[i] = new students2();//allocating memory of every index
System.out.println("Enter the details of the students");
System.out.println("Enter the name");
obj[i].name = sc.next();
System.out.println("Enter the usn");
obj[i].usn = sc.next();
System.out.println("Enter the branch");
obj[i].branch = sc.next();
System.out.println("Enter the phn");
obj[i].phn = sc.nextLong();
}
for (i=0; i<n; i++){
System.out.println("the details of "+obj[i].name+" is:");
System.out.println("USN is "+obj[i].usn);
System.out.println("branch is "+obj[i].branch);
System.out.println("phn is "+obj[i].phn);
System.out.println("-------------------------------");
}
}
}