-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentList.java
More file actions
37 lines (33 loc) · 1004 Bytes
/
StudentList.java
File metadata and controls
37 lines (33 loc) · 1004 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
import java.util.Scanner;
public class StudentList {
String Name;
int Age;
int rollNumber;
public StudentList(int roll, String name, int age) {
this.Name = name;
this.Age = age;
this.rollNumber = roll;
}
@Override
public String toString() {
return "StudentList: {" +
"Name='" + Name + '\'' +
", Age=" + Age +
", rollNumber=" + rollNumber +
'}';
}
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int i = 1;
while (i <= 5) {
System.out.printf("Enter your %d student name: ", i);
String name = sc.next();
System.out.println("Enter your student age: ");
int age = sc.nextInt();
StudentList list = new StudentList(i, name, age);
System.out.println(list);
i++;
}
sc.close();
}
}