Write a java program to ask user to input four lines. Yourprogram will store the four lines in a String array (create aString array of size 4). Once the input is complete, your programwill output the total number of words in the String array andprint all words on a separate line.
PS: Use StringTokenizer class to count and print tokens.
A sample output of the program is given below:
Input any four linesEnter line 1:Twinkle, twinkle, little star,
Enter line 2:How I wonder what you are!Enter line 3:Up above the world so high,
Enter line 4:Like a diamond in the sky.Twinkle,twinkle,littlestar,
HowIwonderwhatyou
are!
Upabovethe
worldsohigh,
Likeadiamondinthe
sky.Total words in 4 lines: 22
Write a java program to ask user to input four lines. Your program will store the four lines in a String array (create a
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am