-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathProgram65.java
39 lines (32 loc) · 1.1 KB
/
Program65.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
/* Program 65
Write a program to declare a class Student with integer data type for roll number, string for name and standard and char for section. The class must have functions for input with parameters, print and the main funciton to create an object and display its details in a formatted manner.
06/08/24 */
import java.util.Scanner;
public class Student {
int roll;
String name;
String standard;
char section;
public void input(int r, String n, String st, char se) {
roll = r;
name = n;
standard = st;
section = se;
}
public void print() {
System.out.println("Roll No\tName\tGrade\tSection\n" + roll + "\t" + name + "\t" + standard + "\t" + section);
}
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
Student s = new Student();
System.out.print("Enter roll no: ");
int r = sc.nextInt();
System.out.print("Enter name: ");
String n = sc.next();
System.out.print("Enter standard: ");
String st = sc.next();
System.out.print("Enter section: ");
s.input(r, n, st, sc.next().charAt(0));
s.print();
}
}