ITEC 120 LAB 9 Back to Lab index page

Alphabet fun

You will write Java program that will ask the user to enter one line of text. You will then output that text one character per line.

Sample 1

Program outputs: Please enter a line of text (type QUIT to quit):
User inputs: Chicken soup.
Program outputs:

C
h
i
c
k
e
n

s
o
u
p
.
Please enter a line of text (type QUIT to quit):

User inputs: Yippee Skippee!
Program outputs: Y
i
p
p
e
e

S
k
i
p
p
e
e
!
Please enter a line of text (type QUIT to quit):
User inputs: QUIT
Program outputs: Goodbye!

You will need to use the String methods charAt, length, and equals. You'll also need to use some loops.

To use incremental development to solve this problem you might want to first figure out how to get the string from the user and print it on one line. Then, figure out how to loop: continue to ask the user to enter a string until they type QUIT. Then, figure out how to print one character per line.

LAB CHALLENGE: Once you get this to work, make your program quit no matter how the user types quit. In other words, they can type "QUIT", "Quit", "quit", or "qUiT", etc, and the program will still quit.

Once you have your program working, show your lab to the Peer Instructor to be checked off.