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

1. Design a program to search a word for letters that the user enters. Declare a

ID: 3654724 • Letter: 1

Question

1. Design a program to search a word for letters that the user enters. Declare a Boolean array of size 26 to represent each letter of the alphabet. (Remember that the alphabet contains 52 characters if you count uppercase and lowercase, so your program converts all the letters by the user to the same case). You do not need to initialize the elements of this array to false at declaration, because false is the default value when a Boolean array is initialized. If the program finds within the word a letter that the user entered, change the value of the array element that matches the alphabetic characters by position to true.

Design a method that prompts the user for a letter to be found and returns the response. Design another method that counts the number of occurrences of a letter entered by the user in a word and returns that count. Design yet another method that displays the letters entered by the user that are also present in the word. These methods are called by the method main.

Following is a copy of the screen results that might appear after running your program, depending on the date entered. The input entered by the user is in bold.

This is a program that counts each time a letter in the alphabet occurs in a word.

Lastly, it would be a huge help if you could comment your code to better help be understand each step. Thanks!

Please enter a word: howdy

The word howdy has 5 characters.

What letter would you like to guess? (Enter zero to quit.) a

There are 0 A

Explanation / Answer

package Cramster; import java.util.Scanner; public class Alphabet { private boolean[] letter = new boolean[26]; private int[] letterCount = new int[26]; public void setLetter(String word) { //Converting the passed word into Lower Case and dividing it into a //Character Array using String methods .toLowerCase() and .toCharArray() char[] letters = word.toLowerCase().toCharArray(); for(int i =0; i