-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStudent.java
More file actions
54 lines (39 loc) · 1.07 KB
/
Student.java
File metadata and controls
54 lines (39 loc) · 1.07 KB
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
51
52
53
54
public class Student {
int id,total=0;
float average=0;
String name;
int[]mark;
static int count;
Student(int id,String name,int[]mark){
this.mark=mark;
this.id=id;
this.name=name;
count++;
totalmark(mark);
averagemark();
}
int totalmark(int[] a){
for(int tt: a){
total=total+tt;
}
return total;
}
float averagemark(){
average=total/mark.length;
return average;
}
void display(){
System.out.println("Student Id : "+id);
System.out.println("Name : "+name);
System.out.println("Total mark : "+total);
System.out.println("average : "+average);
System.out.println("----------------------");
}
public static void main(String[] args) {
Student s=new Student(101,"Naveen",new int[]{10,20,30});
Student s1=new Student(102,"arun",new int[]{10,50,40});
s.display();
s1.display();
System.out.println("Total student: "+ count);
}
}