Question: Keyboard Input Create a program called EightLines.java. This program should read in exactly eight lines of text ( as returned by Scanner.nextLine ( ) )

Keyboard Input Create a program called EightLines.java. This program should read in exactly eight lines of text (as returned by Scanner.nextLine()) from the keyboard input. Each line may contain 0 or more words.(A word is any set of non-space characters, separated from other words on the same line by one or more spaces.) Each input word should be printed alone on a line. What kinds of test cases can you think of? - Lines with 0,1, or more than 1 words - Fewer than 8, exactly 8, or more than 8 input lines. How do you detect if the input contains fewer than 8 lines? What method should you use? If an input line contains no words, what should the program do? The specification says only to print words at the input, so such lines should be "counted as lines" but should not yield any output. How do you want to get each word from each line? You could use String.split(), or you could make a new Scanner for the line, reading from the String that contains the line.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!