-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentDetails.java
59 lines (57 loc) · 1.31 KB
/
StudentDetails.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**A java program to input the student details and print them
* using class, obj and constructor
* @author DEEEPAK SINGH */
import java.util.Scanner;
class Student
{
Scanner sc = new Scanner(System.in);
String name,regno,dob;
int roll;
Student()
{
String name = "Enter Your Name";
String regno = "0123456789";
String dob = "01/01/2001";
roll = 1;
}
Student(int roll,String nm,String regno,String db)
{
roll = roll;
name = nm;
regno = regno;
dob = db;
}
void input()
{
System.out.print("Enter Roll : ");
roll = sc.nextInt();
System.out.print("Enter Name : ");
sc.nextLine();
name = sc.nextLine();
System.out.print("Enter Reg. No. : ");
regno = sc.nextLine();
System.out.print("Enter D.O.B : ");
dob = sc.nextLine();
}
void output()
{
System.out.println("--------------------------");
System.out.println("Name : "+name);
System.out.println("Roll No. : "+roll);
System.out.println("Reg No. : "+regno);
System.out.println("D.O.B : "+dob);
}
}
class StudentDetails
{
public static void main(String[] args)
{
Student s = new Student(1,"Your Name","000000000","01/01/2001");
s.output();
Student s1 = new Student();
System.out.println("------------------------");
s1.output();
s1.input();
s1.output();
}
}