forked from VimalKrishnaRao/OOP-in-Java-Lab
-
Notifications
You must be signed in to change notification settings - Fork 0
/
3StudentClass.java
43 lines (39 loc) · 940 Bytes
/
3StudentClass.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
import java.util.Scanner;
class Student
{
String name;
int rollNo;
int marks[] = new int[5];
void read()
{
Scanner sc = new Scanner(System.in);
System.out.print("Enter Student's name: ");
name = sc.nextLine();
System.out.print("Enter Student's roll number: ");
rollNo = sc.nextInt();
System.out.println("Enter marks in 5 subjects: ");
for (int i = 0; i < 5; i++)
{
marks[i] = sc.nextInt();
}
}
void display()
{
System.out.println("Name: " + name);
System.out.println("Roll number: " + rollNo);
System.out.println("Marks in 5 subjects: ");
for (int i = 0; i < 5; i++)
{
System.out.println(marks[i]);
}
}
}
class Main
{
public static void main(String args[])
{
Student s = new Student();
s.read();
s.display();
}
}