Write a static method named countLastDigits that accepts an array of integers as a parameter and examines its elements to determine how many end in 0, how many end in 1, how many end in 2 and so on. Your method will return an array of counters. The count of how many elements end in 0 should be stored in its element at index 0, how many of the values end in 1 should be stored in its element at index 1, and so on.

Respuesta :

Answer:

See explaination for the program code

Explanation:

code:

public static int[] countLastDigits(int[] list) {

int[] count = new int[10];

for (int i = 0; i < list.length; i++) {

int digit = list[i] % 10;

count[digit]++;

}

return count;

}

fichoh

The program which counts the number of elements with ends with a certain digit is given below with, elements ending with 0 as index, 1 and so on.

public static int[] countLastDigits(int[] list) {

#initializes a function named countLastDigits

int[] count = new int[10];

for (int i = 0; i < list.length; i++) {

#a for loop to iterate over the array created

int digit = list[i] % 10;

count[digit]++;

#appends to counts variable

}

return count;

}

Learn more : https://brainly.com/question/18478903