subject
Engineering, 12.06.2020 05:57 Vampfox

The CountLetters application is limited to counting letters in a single word. Modify the CountLetters application to count the letters in an entire phrase, which contains spaces. Care must be taken to ignore the spaces and any other non alphabetic character found in the phrase. Be sure to change comments and variable names appropriately so that the reader of the application code understands that the letters in a phrase are counted. import java. util. Scanner;

public class CountLetters {

public static void main(String[] args) {
final int LOW = 'A'; //smallest possible value
final int HIGH = 'Z'; //highest possible value
int[] letterCounts = new int[HIGH - LOW + 1];
Scanner input = new Scanner(System. in);
String phrase;
char[] wordLetters;
int offset; //array index

/* prompt user for a phrase */
System. out. print("Enter a phrase: ");
phrase = input. nextLine();
input. close();

/* convert word to char array and count letter occurrences */
phrase = phrase. toUpperCase();
wordLetters = phrase. toCharArray();
for (int letter = 0; letter < wordLetters. length; letter++) {
offset = wordLetters[letter] - LOW;
letterCounts[offset] += 1;
}

/* show letter occurrences */
for (int i = LOW; i <= HIGH; i++) {
System. out. println((char)i + ": " + letterCounts[i - LOW]);
}
}

}

ansver
Answers: 3

Another question on Engineering

question
Engineering, 04.07.2019 18:10
Aturning operation is performed with following conditions: rake angle of 12°, a feed of 0.35 mm/rev, and a depth of cut of 1.1 mm. the work piece is aluminum alloy 6061 with t6 heat treatment (a16061-t6). the resultant chip thickness was measured to be 1.0 mm. estimate the cutting force, fc. use shear stress of 207 mpa and coefficient of friction on the tool face of 0.6.
Answers: 1
question
Engineering, 04.07.2019 18:20
Agas mixture consists of 8 kmol of h2 and 2 kmol of n2. determine the mass of each gas and the apparent gas constant of the mixture.
Answers: 3
question
Engineering, 04.07.2019 18:20
Water vapor initially at 10 bar and 400 °c is contained within a piston-cylinder assembly. the water lost heat to the surrounding according to isochoric (iso-volumetric) process until its temperature is 150 °c. the water is then condensed isothermally to saturated liquid. for the water as a system, calculate the work in kj/kg
Answers: 2
question
Engineering, 04.07.2019 19:10
Aplate of dimensions 3 m x 3 m is placed 0.37 mm apart from a fixed plate. the plate requires a force of 2n to move at speed of 45 cm/s. evaluate the viscosity of the fluid in between the plates
Answers: 3
You know the right answer?
The CountLetters application is limited to counting letters in a single word. Modify the CountLetter...
Questions
question
English, 24.11.2020 20:50
question
Mathematics, 24.11.2020 20:50
question
Advanced Placement (AP), 24.11.2020 20:50
question
SAT, 24.11.2020 20:50
question
Physics, 24.11.2020 20:50
question
Mathematics, 24.11.2020 20:50
Questions on the website: 13722363