Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program named ClassifyScores that classifies a series of scores into dec

ID: 3642179 • Letter: W

Question

Write a program named ClassifyScores that classifies a series of scores into deciles (0-9,10-19,20-29

Explanation / Answer

Please find the below program in Java import java.util.Arrays; import java.util.HashMap; import java.util.Map; import java.util.Scanner; public class ArrayProgramming { public static void main(String[] args) { Integer[] array0 = { 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 }; Integer[] array1 = { 10, 11, 12, 13, 14, 15, 16, 17, 18, 19 }; Integer[] array2 = { 20, 21, 22, 23, 24, 25, 26, 27, 28, 29 }; Integer[] array3 = { 30, 31, 32, 33, 34, 35, 36, 37, 38, 39 }; Integer[] array4 = { 40, 41, 42, 43, 44, 45, 46, 47, 48, 49 }; Integer[] array5 = { 50, 51, 52, 53, 54, 55, 56, 57, 58, 59 }; Integer[] array6 = { 60, 61, 62, 63, 64, 65, 66, 67, 68, 69 }; Integer[] array7 = { 70, 71, 72, 73, 74, 75, 76, 77, 78, 79 }; Integer[] array8 = { 80, 81, 82, 83, 84, 85, 86, 87, 88, 89 }; Integer[] array9 = { 90, 91, 92, 93, 94, 95, 96, 97, 98, 99 }; HashMap map = new HashMap(); map.put(array0, 0); map.put(array1, 0); map.put(array2, 0); map.put(array3, 0); map.put(array4, 0); map.put(array5, 0); map.put(array6, 0); map.put(array7, 0); map.put(array8, 0); map.put(array9, 0); Scanner sc = new Scanner(System.in); System.out.println("Enter number"); int j = 0; int k = -1, count0 = 0, count1 = 0, count2 = 0, count3 = 0, count4 = 0, count5 = 0, count6 = 0, count7 = 0, count8 = 0, count9 = 0; while ((j = sc.nextInt()) != -1) { if (j < 100) { k = Arrays.binarySearch(array0, j); if (k > 0) { count0++; map.put(array0, count0); } k = Arrays.binarySearch(array1, j); if (k > 0) { count1++; map.put(array1, count1); } k = Arrays.binarySearch(array2, j); if (k > 0) { count2++; map.put(array2, count2); } k = Arrays.binarySearch(array3, j); if (k > 0) { count3++; map.put(array3, count3); } k = Arrays.binarySearch(array4, j); if (k > 0) { count4++; map.put(array4, count4); } k = Arrays.binarySearch(array5, j); if (k > 0) { count5++; map.put(array5, count5); } k = Arrays.binarySearch(array6, j); if (k > 0) { count6++; map.put(array6, count6); } k = Arrays.binarySearch(array7, j); if (k > 0) { count7++; map.put(array7, count7); } k = Arrays.binarySearch(array8, j); if (k > 0) { count8++; map.put(array8, count8); } k = Arrays.binarySearch(array9, j); if (k > 0) { count9++; map.put(array9, count9); } } else { System.out.println("number > 99 is not valid"); break; } } System.out.println("Decile Scores"); System.out.println("[0-9]" + map.get(array0)); System.out.println("[10-19]" + map.get(array1)); System.out.println("[20-29]" + map.get(array2)); System.out.println("[30-39]" + map.get(array3)); System.out.println("[40-49]" + map.get(array4)); System.out.println("[50-59]" + map.get(array5)); System.out.println("[60-69]" + map.get(array6)); System.out.println("[70-79]" + map.get(array7)); System.out.println("[80-89]" + map.get(array8)); System.out.println("[90-99]" + map.get(array9)); } } Output: Enter number 1 2 3 4 5 21 23 35 34 35 6 7 45 56 67 89 99 101 number > 99 is not valid Decile Scores [0-9]7 [10-19]0 [20-29]2 [30-39]3 [40-49]1 [50-59]1 [60-69]1 [70-79]0 [80-89]1 [90-99]1
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote