Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please do help me to finish this java coding. Thank you in advance. Question 2: [10 marks] Write a java a program to count the
Please do help me to finish this java coding. Thank you in advance.
Question 2: [10 marks] 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 getRandomUpperCaseLetter0 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. c: YoOp \Assignment java CountLettersInArray The uppercase letters are: T GKUBKKDFZJFPCSHY TOEFEGHCJAGITPUEINKA W VOZKXNOVTMOTIMTTCMN OF BU AU W P RSYPMCT R F D MF Q R \& 5 X X TZTEP QXFCUEIU 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 62V2N624Z c: \oop\Assignment>java CountlettersinArray The uppercase letters are: CBV B NKJKANDI OSUL 60HZZ H DXKLIIKKICTJSEIOLP JX AEODVUCN JXCOEBJTNNGI HT PTLOIDRNSWI A I I KOH P X A B VRH HKZDOET TA Q NKKK The occurrences of each letter are: 4 A 3 B 4 C 5 D 4 E B F 3 G 5 H 10 I 5 J 24V3WH 8 Y2Z II RandomCharacter.java public class RandomCharacter \{ f Generate a random character between ch 1 and ch2 public static char getRandomCharacter(char ch1, char ch2) \{ retum (char)(ch1 + Math.randomn * ( ch2 - ch1 +1)); 1 J Generate a random lowercase letter *I public static char getRandomLowerCaseLetter[\{ retum getRandomCharacter('a', 'z'); f j Generate a random uppercase letter * public static char getRandomUpperCaseLetter[\{ retum getRandomCharacter('A', 'Z'); ) J Generate a random digit character / public static char getRandomDigitCharacter() \{ retum getRandomCharacter('0', y)Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started