-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudentDemo.java
More file actions
34 lines (32 loc) · 794 Bytes
/
StudentDemo.java
File metadata and controls
34 lines (32 loc) · 794 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
class Stu{
int RollNumber;
String Name;
int m1,m2,m3;
float avg;
Stu(int RollNumber,String Name,int m1,int m2,int m3){
this.RollNumber = RollNumber;
this.Name = Name;
this.m1 = m1;
this.m2 = m2;
this.m3 = m3;
}
public void CalculateAverage() {
avg=(m1+m2+m3)/3;
}
public void DisplayDetails() {
System.out.println("Roll Number:"+RollNumber);
System.out.println("Name:"+Name);
System.out.println("Mark 1:"+m1+"\tMark 2:"+m2+"\tMark 3:"+m3);
System.out.println("Average:"+avg);
}
}
public class StudentDemo {
public static void main(String[]args) {
Stu Student1=new Stu(1,"Sara",87,66,78);
Student1.CalculateAverage();
Student1.DisplayDetails();
Stu Student2=new Stu(2,"Zerin",97,69,70);
Student2.CalculateAverage();
Student2.DisplayDetails();
}
}