Question
Write a program that keeps a count of the lines in the input and prints out the line number, the number of characters in the
Write a program that keeps a count of the lines in the input and prints out the line number, the number of characters in the line followed by the line itself.
Input -- The input will be one or more lines of characters that have been typed in by the user.
Output --The output will have for each line, the line number followed by a space, followed by the number of characters in the line, followed by a space, followed by the line that was entered
Sample Input
hello there!
I am a bee
Sample Output
1 12 hello there!
2 10 I am a bee
--HINT Have a variable (say named count) that you keep incrementing by 1 every time you read a new line. Initial value should be 1. Also, use the String's length method to get the length of the line.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started