-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathOOPS6.java
More file actions
50 lines (39 loc) · 838 Bytes
/
OOPS6.java
File metadata and controls
50 lines (39 loc) · 838 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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
import java.util.Arrays;
import java.util.Scanner;
class stu{
private String Sname;
private int [] marks;
private int total;
private double avg;
public stu()
{
Sname="";
marks=new int[0];
total=0;
avg=0;
}
public void assign(String n,int [] m)
{
this.Sname=n;
this.marks=m;
compute();
}
public void display() {
System.out.println("Student Name "+Sname);
System.out.println("Marks"+Arrays.toString(marks));
System.out.println("Total :"+total);
System.out.println("Avaerage Marks "+avg);
}
public void compute()
{ for (int a:marks)
total=total+a;
avg=total/(marks.length);
}
}
public class OOPS6 {
public static void main(String[] args) {
stu A=new stu();
A.assign("Lucifer",new int [] {12,34,55,});
A.display();
}
}