-
Notifications
You must be signed in to change notification settings - Fork 0
/
student.java
42 lines (41 loc) · 937 Bytes
/
student.java
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
import java.util.Scanner;
public class student
{
String name,branch_name;
int id;
public void setMethod()
{
Scanner sc = new Scanner(System.in);
System.out.println("Enter student name");
name=sc.next();
System.out.println("Enter branch name");
branch_name=sc.next();
System.out.println("Enter student ID");
id = sc.nextInt();
}
public void getMethod()
{
System.out.println("-----You Student Details-----");
System.out.println("Name=" + name);
System.out.println("Branch=" + branch_name);
System.out.println("Id=" +id);
}
public static void main(String[] args)
{
student s1[] = new student[5];
System.out.println("Enter Student Details::");
int i=1;
do
{
System.out.println(i);
s1[i]=new student();
s1[i].setMethod();
i++;
}while(i<=5);
for(i=1;i<=5;i++)
{
System.out.println(i);
s1[i].getMethod();
}
}
}