Ask Question

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.

+2
Answers (1)
  1. 8 June, 22:33
    0
    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;

    }
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Write a static method named countLastDigits that accepts an array of integers as a parameter and examines its elements to determine how ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers