Skip to content

Commit 7d04231

Browse files
Added the answers for Tutorial2 Q1
1 parent 40b31eb commit 7d04231

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
class Main {
2+
public static void main(String[] args) {
3+
Student s1 = new Student();
4+
s1.get("che",21,78,50);
5+
s1.disp();
6+
}
7+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
class Student{
2+
String name;
3+
int sub1;
4+
int sub2;
5+
int sub3;
6+
int Avg;
7+
void get(String n, int a, int b, int c) {
8+
name = n;
9+
sub1 = a;
10+
sub2 = b;
11+
sub3 = c;
12+
}
13+
14+
void disp() {
15+
Avg = (sub1 + sub2+sub3 )/2;
16+
System.out.println("Name=" + name);
17+
System.out.println("Average=" + Avg);
18+
}
19+
}

0 commit comments

Comments
 (0)