26 lines
823 B
Java
26 lines
823 B
Java
import java.util.Scanner;
|
|
import java.util.ArrayList;
|
|
|
|
public class Loop {
|
|
public static void main(String[] args) {
|
|
Scanner console = new Scanner(System.in);
|
|
ArrayList<String> words = new ArrayList<>();
|
|
System.out.println("Please enter \"STOP\" to stop.");
|
|
while (true) {
|
|
System.out.print("Enter a word: ");
|
|
String next_word = console.next();
|
|
words.add(next_word);
|
|
if (next_word.equals("STOP")) {
|
|
break;
|
|
}
|
|
}
|
|
System.out.println("Here are the word lengths:");
|
|
for (int i = 0; i < words.size(); i++) {
|
|
String word = words.get(i);
|
|
System.out.println(word + " " + word.length());
|
|
}
|
|
System.out.println("The last word was \"STOP\" of course.");
|
|
|
|
}
|
|
}
|