Code
int myArray[];
int nElements = 100;
int count = 0;
myArray = new int[nElements];
for (int i=0; i < nElements; i++){
int randomInt = (int)random(100);
myArray[i] = randomInt;
}
for (int i=0; i< nElements; i++){
if (myArray[i] > 90){
count ++;
}
}
println ("The number of values over 90 are " + count + " values");
0502 - Arrays: Conditional testing on Array Elements
Statement:
// Below is some code which fills an array (called myArray)
// with 100 random integers between 0 and 100.
// Write some code which counts the number of values
// stored in this array which are greater than 90.
// You may not modify the code below; assume your code follows it.
// Report the counted total with a println().
int myArray[];
int nElements = 100;
myArray = new int[nElements];
for (int i=0; i < nElements; i++){
int randomInt = (int)random(100);
myArray[i] = randomInt;
}
hide statement