Answer:
public class Main
{
public static void main(String[] args) {
int nPositive = 0;
int[][] a2d = {{-7,28, 92}, {0,11,-55}, {109, -25, -733}};
for (int i = 0; i < a2d.length; i++) {
for(int j = 0; j < a2d[i].length; j++) {
if(a2d[i][j] > 0){
nPositive++;
}
}
}
System.out.println(nPositive);
}
}
Explanation:
*The code is in Java.
Initialize the nPositive as 0
Initialize a two dimensional array called a2d
Create a nested for loop to iterate through the array. If an element is greater than 0, increment the nPositive by 1
When the loop is done, print the nPositive
Answer:
const a2d = [[7,28, 92], [0,11,-55], [109, -25, -733]];
let nPositive = a2d.reduce((a,c) => a + c.filter(n => n>0).length, 0);
console.log(nPositive);
Explanation:
Just for fun, I want to share the solution in javascript when using the powerful list operations. It is worthwhile learning to understand function expressions and the very common map(), reduce() and filter() primitives!
To build a user interface that contains graphical components, the components ____. must each be added to a separate panel. must be added directly to a frame component. must be added to a panel that is contained within a frame. must be added to a frame that is contained within a panel.
Answer:
To build a user interface that contains graphical components, the components must be added to a panel that is contained within a frame.
Explanation: