-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram64.java
49 lines (38 loc) · 1.37 KB
/
Program64.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
/* Program 64
Write a program to declare a class Student with integer data type for rollno string for name and standard and character for section. The class must have functions for input() to accept data from the user, print and the main function to create 3 objects and display their details in a formatted manner.
02/08/24 */
import java.util.Scanner;
public class Student {
int rollno;
String name;
String standard;
char section;
public void input() {
Scanner sc = new Scanner(System.in);
System.out.print("Enter roll number: ");
rollno = sc.nextInt();
System.out.print("Enter name: ");
name = sc.next();
System.out.print("Enter standard and section: ");
standard = sc.next();
section = sc.next().charAt(0);
}
public void print() {
System.out.println(rollno + "\t" + name + "\t" + standard + "\t\t" + section);
}
public static void main(String args[]) {
Student s1 = new Student();
Student s2 = new Student();
Student s3 = new Student();
System.out.println("Student 1: ");
s1.input();
System.out.println("Student 2: ");
s2.input();
System.out.println("Student 3: ");
s3.input();
System.out.println("Roll No\tName\tStandard\tSection");
s1.print();
s2.print();
s3.print();
}
}