Last active
August 12, 2018 14:27
-
-
Save dheysonalves/768c4ff68ad53c66f4c2bb45e390727c to your computer and use it in GitHub Desktop.
java-frequency-test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package javacomomethods; | |
public class NewClass { | |
public static void main(String[] args) { | |
int[] x = {5,8,9,6,2,1,3,3,1,2,3,4,14}; | |
int[] frequencia = new int [8]; | |
for (int i = 0; i < x.length; i++) { | |
try { | |
++frequencia[x[i]]; | |
} catch (Exception e) { | |
System.out.println(e); | |
System.out.printf(" responses[%d] = %d%n%n", i, x[i]); | |
} | |
} | |
System.out.printf("%s%10s%n", "contagem ", "frequencia"); | |
for (int count = 0; count < frequencia.length; count++) { | |
System.out.printf("%6d%10d%n",count, frequencia[count]); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment