-
Notifications
You must be signed in to change notification settings - Fork 28
Expand file tree
/
Copy path1a.java
More file actions
43 lines (43 loc) · 1011 Bytes
/
1a.java
File metadata and controls
43 lines (43 loc) · 1011 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
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
import java.util.Scanner;
public class Student
{
private String usn, name, branch, phone;
public Student(String usn, String name, String branch, String phone)
{
super();
this.usn = usn;
this.name = name;
this.branch = branch;
this.phone = phone;
}
@Override
public String toString()
{
return "Student [USN = " + usn + ", NAME = " + name + ", BRANCH = " + branch
+ ", PHONE NUMBER = " + phone + "]";
}
public static void main(String args[])
{
int i;
String usn, branch, name, phone;
Scanner s = new Scanner(System.in);
System.out.println("Enter number of Students: ");
int n = s.nextInt();
Student[] students = new Student[n + 1];
for(i = 1; i<= n; i ++)
{
System.out.println("Enter student "+ i +" details\n");
System.out.println("Give Student Details USN, Name, Branch, Phone Number");
usn = s.next();
name = s.next();
branch = s.next();
phone = s.next();
students[i] = new Student(usn, name, branch, phone);
}
System.out.println("DATABASE:");
for(i = 1; i <= n; i ++)
{
System.out.println(students[i]);
}
}
}