Characters
You have been given a list of verbs to print on a page, and you want to know if there's enough ink in your printer to print all the characters.
Diese Übung ist Teil des Kurses
Intermediate Java
Anleitung zur Übung
- Find how many words are in the
conjugationArray. - Choose the proper comparison operator to make sure we stay below
tabLength. - Select the appropriate updating operator to increase
iat the end of each run. - Write down the variable to make sure that we get each
wordfromconjugation.
Interaktive Übung
Vervollständige den Beispielcode, um diese Übung erfolgreich abzuschließen.
class CharacterCounter {
public static void main(String[] args) {
String[] conjugation = {"hide", "hindered", "hiding", "hidden", "hindering", "hid", "hides", "hinder"};
// Retrieve the number of words in the array by calling the correct field
int tabLength = conjugation.____;
int numberOfCharacters = 0;
// Choose the appropriate operators (logical and increment)
for (int i = 0; i ____ tabLength; i____) {
// Give the proper variable to get each word out of conjugation
String word = conjugation[____];
numberOfCharacters += word.length();
}
System.out.println("There are " + numberOfCharacters + " characters in the list");
}
}