Engineering
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]);
}
}

}

answer
Answers: 3

Other questions on the subject: Engineering

image
Engineering, 04.07.2019 18:10, ashleybaber4966
If a particle moves along a path such that r : (3 sin t) m and ? : 2t rad, where t is in seconds. what is the particle's acceleration in m/s in 4 seconds? a)- 16.43 b)- 16.29 c)- 15.21 d)- 13.79
Answers: 1
image
Engineering, 04.07.2019 18:10, soreese02
An ideal otto cycle with air as the working fluid has a compression ratio of 8. the minimum and maximum temperatures in the cycle are 300 k and 1340 k. use constant specific heats at room temperature to determine (a) the amount of heat transferred to the air during the heat- addition kj/kg, (b) the thermal efficiency, and (c) the thermal efficiency of a carnot cycle ope limits. process, in rating between the same temperature
Answers: 2
image
Engineering, 04.07.2019 18:10, katelynn73
Atmospheric air has a temperature (dry bulb) of 80° f and a wet bulb temperature of 60° f when the barometric pressure is 14.696 psia. determine the specific humidity, grains/lb dry air. a. 11.4 c. 55.8 d. 22.5 b. 44.1
Answers: 1
image
Engineering, 04.07.2019 18:10, 0436500
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
Do you know the correct answer?
The CountLetters application is limited to counting letters in a single word. Modify the CountLetter...

Questions in other subjects:

Konu
Mathematics, 21.05.2021 16:10