Question: The following question is based on Java programming language. Make sure that the program is runnable using java program . Write a java a program
The following question is based on Java programming language. Make sure that the program is runnable using java program.
Write a java a program to count the occurrences of each letter in an array of characters. Generates 100 uppercase letters randomly and assigns them to an array of characters. You can obtain a random letter by using the getRandomUpperCaseLetter() method in the RandomCharacter class provided (refer to RandomCharacter.java).
Count the occurrences of each letter in the array. To do so, create an array, say counts, of 26 int values, each of which counts the occurrences of a letter, as shown in the chars array stores 100 characters, and the counts array stores 26 counts, each of which counts the occurrences of a letter. The sample outputs are given below:



// RandomCharacter.java
public class RandomCharacter {
/** Generate a random character between ch1 and ch2 */
public static char getRandomCharacter(char ch1, char ch2) {
return (char)(ch1 + Math.random() * (ch2 - ch1 + 1));
}
/** Generate a random lowercase letter */
public static char getRandomLowerCaseLetter() {
return getRandomCharacter('a', 'z');
}
/** Generate a random uppercase letter */
public static char getRandomUpperCaseLetter() {
return getRandomCharacter('A', 'Z');
}
/** Generate a random digit character */
public static char getRandomDigitCharacter() {
return getRandomCharacter('0', '9');
}
/** Generate a random character */
public static char getRandomCharacter() {
return getRandomCharacter('\u0000', '\uFFFF');
}
}
C: \00P\Assignment>java CountLettersinArray The uppercase letters are: T GKUBKXK DF ZX J X F P C S H Y TO E F E G HC J A G I T P UE I NKA O F B U UWPR S Y P MC T R F D MF Q R NSX T Z T Z T EPQXFCUEIU The occurrences of each letter are: 3 A 2 B 5 C 2 D 5 E 7 F 3 G 3 H 4 I 2 J 5KO4M4N4L5P3Q3R3S11T 6U2V2W62Y4Z C: \OOP\Assignment>. C: \00P\Assignment>java CountLettersInArray The uppercase letters are: C B VVNK J K ANDIOS ULGO HZ H DXWWLI I K I C T JS E I OLP JX WEODVUCN JXCOOE J JNNGI H T P TLGG I DQNSWI A I I KO H P XABVRHMKZDOETTAQNKKK The occurrences of each letter are: 4 A 3 B 4 C 5 D 4 E 0 F 3 G 5 H 10 I 5 J 8K4L1M7N7N33P2Q1R3S6T 2U4V3WH0Y2Z c: \OOP \Assignment> C: \OOP \Assignment>java CountLettersinArray The uppercase letters are: V F V I K Z E G Q K K H S O Q V C K U T E X P L S N U W F L A A V V C J H J F B R I J D E Y P G A S Q T O P O W H Z A A D F B S T K K N Q X T Y L Z W P H B C V K C H L A X Q B F Q M C K M E X V O S N The occurrences of each letter are: 6 A 4 B 5 C 2 D 4 E 5 F 2 G 5 H 2 I 3 J 8 K 4 L 2 M 3 N 4 O 4 P 6 Q 1 R 5 S 4 T 2 U 7 V 3 W 4 X 2 Y 3 Z C: \OOP \Assignment>
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
