How can I change the " if" to fit the condition : "Determine the number of sixes in each group " import java.util.Arrays; public class DimArray { public static void main(String[] args) { // TODO Auto-generated method stub String[] groupNames = new String[] {"KST 8", "KST9"}; int[][] marks = { {6,5,3,4,6}, {5,6,3,4}, }; int countOfGroups= marks.length; int[] countsix= new int[countOfGroups]; for(int group=0; group
How can I change the " if" to fit the condition : "Determine the number of sixes in each group "
import java.util.Arrays;
public class DimArray {
public static void main(String[] args) {
// TODO Auto-generated method stub
String[] groupNames = new String[] {"KST 8", "KST9"};
int[][] marks = {
{6,5,3,4,6},
{5,6,3,4},
};
int countOfGroups= marks.length;
int[] countsix= new int[countOfGroups];
for(int group=0; group<countOfGroups; group++) {
int count=0;
int countStudentsInCurrentGroup= marks[group].length;
for(int st=0; st<countStudentsInCurrentGroup; st++) {
if(marks[group][st]==6)
count ++;
}
}
System.out.println("Result");
for(int group=0; group<countOfGroups; group++) {
System.out.printf("Groups %s Grades: %s Number ot students: %d Number of sixes: %d%n",
groupNames[group],
Arrays.toString(marks[group]),
marks[group].length,
count[group]
);
}
}
}
Step by step
Solved in 3 steps with 1 images