Write a java program to ask user to input four lines. Your program will store the four lines in a String array (create a

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

Write a java program to ask user to input four lines. Your program will store the four lines in a String array (create a

Post by answerhappygod »

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
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply