-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentConst.java
More file actions
46 lines (40 loc) · 1.06 KB
/
StudentConst.java
File metadata and controls
46 lines (40 loc) · 1.06 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
45
46
/*Author : Ganesh Chandran
Date : [Date]
Description : [Question] */
package LAB;
import java.util.Scanner;
class Student{
String name;
int rollNumber;
String dept;
Student(String studentName,int roll,String department){
name=studentName;
rollNumber=roll;
dept=department;
}
public void StudentInfo() {
System.out.println("Name: " + name);
System.out.println("Roll Number: " + rollNumber);
System.out.println("Department: " + dept);
}
}
public class StudentConst {
public static void main(String[] args) {
String name;
int roll;
String dept;
System.out.println("Enter student details...");
Scanner sc = new Scanner(System.in);
System.out.println("Enter name: ");
name=sc.nextLine();
System.out.println("Enter roll number: ");
roll=sc.nextInt();
System.out.println("Enter Department: ");
dept=sc.nextLine();
Student student= new Student(name,roll,dept);
student.StudentInfo();
Student student1= new Student(name,roll,dept);
student1.StudentInfo();
sc.close();
}
}