My code is supposed to prompt the user for an integer and count the occurrences of each digit in the integer. But it outputs nothing. Please help and here's my code.
import java.util.Scanner;
public class NumberCounts {
public static void main(String [] args) {
Scanner scan = new Scanner(System.in);
int arr [] = new int [10];
int num;
int outcome;
System.out.println(" Enter a number: ");
num = scan.nextInt();
while ( num != 0){
outcome = num % 10;
arr[num % 10]+=1;
num /= num;
}
for ( int i = 0; i <= arr.length; i++){
System.out.println(i + " : " + arr[i]);
}
}
}