7
Forty students were asked the level of quality of food in the student canteen, on a scale from 0 to 10. ( 1 meaning horrific and 10 meaning excellent). Put the 40 responses into an entire array and summarize the search results.
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
final int tamanhoResposta = 40, frequencySize = 11;
int response[] = {5, 10, 6, 7, 3, 7,5 ,6 ,3, 10, 4,5,4,9,8,7,5,6,5,6,4,5,6,7,8,4,3,8,9,10,9,6,5,3,9,5,9,10};
int frequency[] ={0};
for(int i = 0; i < tamanhoResposta; i++){
++frequency[response[i]];
}
System.out.println(" Avaliação ===================== Frequência " );
for(int ii = 0; ii < frequencySize; ii++){
System.out.println(ii + " ");
System.out.println(frequency[ii]);
}
I don’t understand what this part is for, but what it does?
++frequency[response[i]];
He makes that exception:
Exception in thread "main" java.lang.Arrayindexoutofboundsexception: 5
The downvoter could take advantage that came by and answer the question or explain how it can be improved.
– Caffé
downvoter? I don’t understand...
– Aline
@Alinegonzaga his question had 5 positive and one negative votes, totaling 4 points so far. What Caffé suggested in his comment, is that the downvoter (the person who voted negative) came forward to help resolve or improve the issue.
– Bacco
So do I. Thanks for explaining the term.
– Aline