Tugas Algoritma ke 4

import java.util.*;
public class Counter
{
public static void main(String[] args)
{
Scanner scan = new Scanner(System.in);
System.out.print(“MasukkanAngka: “);

int[] array = new int[10];
scan.useDelimiter(“,*”);
for (int i = 0; i <array.length; i++)
{
array[i] = scan.nextInt();
}
Arrays.sort(array);

for (int a = 0; a < 9; a++)
{
int n = 0;
int x = 0;
n = array[a];
x = 1;

while (array[a] == array[a + 1] && a <= 9) {
a++;
x++;
}
System.out.println(“Angka ” + n + ” muncul ” + x + ” kali”);
}
}
}

Leave a Comment

Please note: Comment moderation is enabled and may delay your comment. There is no need to resubmit your comment.