-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathManageHeight.java
More file actions
35 lines (29 loc) · 900 Bytes
/
ManageHeight.java
File metadata and controls
35 lines (29 loc) · 900 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
package C07;
public class ManageHeight {
private int[][] student;
public void setData() {
student = new int[][]{
{170, 180, 173, 175, 177},
{160, 165, 167, 186},
{158, 177, 187, 176},
{173, 182, 181},
{170, 180, 165, 177, 172}
};
}
public void printHeight(int classNo) {
System.out.println("Class No.:" + classNo);
for(int student : student[classNo]) {
System.out.println(student);
}
}
public void printAverage(int classNo) {
System.out.println("Class No.:" + classNo);
int i = 0;
int studentHeightTotal = 0;
for(int student : student[classNo]) {
i++;
studentHeightTotal += student;
}
System.out.println("Height average:" + (double) studentHeightTotal / i);
}
}