-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMethods.java
More file actions
42 lines (26 loc) · 796 Bytes
/
Methods.java
File metadata and controls
42 lines (26 loc) · 796 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
package pack1;
import javax.swing.JOptionPane;
public class Student {
int number;
String name, surname,department;
void register(Student s)
{
s.number=Integer.parseInt(JOptionPane.showInputDialog(null,"Enter Number"));
s.name=JOptionPane.showInputDialog(null,"Enter Name");
s.surname=JOptionPane.showInputDialog(null,"Enter Surname");
s.department=JOptionPane.showInputDialog(null,"Enter Department");
}
void display(Student s)
{
JOptionPane.showMessageDialog(null, s.number+"\n"+s.name+" "+s.surname+"\n"+s.department);
}
public static void main(String[] args) {
Student stu1=new Student();
stu1.register(stu1);
stu1.display(stu1);
Student stu2=new Student();
stu2.register(stu2);
stu2.display(stu2);
stu1.display(stu1);
}
}