-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathStudent.java
More file actions
43 lines (37 loc) · 1.2 KB
/
Copy pathStudent.java
File metadata and controls
43 lines (37 loc) · 1.2 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
package com.programs;
import java.util.Scanner;
public class Student {
String usn,name,branch;
long phone;
void getDetail() {
Scanner in = new Scanner(System.in);
System.out.println("Enter the student USN:");
usn = in.nextLine();
System.out.println("Enter the student name:");
name = in.nextLine();
System.out.println("Enter the student branch:");
branch = in.nextLine();
System.out.println("Enter the student phone:");
phone = in.nextLong();
}
void putDetails() {
System.out.println("USN: "+usn+"\nName: "+name+"\nBranch: "+branch+"\nPhone: "+"\n");
}
public static void main(String[] args) {
int i,n;
System.out.println("Enter the number of students:");
Scanner in = new Scanner(System.in);
n = in.nextInt();
Student a[] = new Student[n];
for(i=0;i<n;i++)
a[i] = new Student();
for(i=0;i<n;i++) {
System.out.println("Enter the details of Student "+(i+1));
a[i].getDetail();
}
for(i=0;i<n;i++) {
System.out.println("The details of Student "+(i+1));
a[i].putDetails();
}
}
}