Javaindepth24
16/09/2022
Java End-Of-File Program
Problem
The problem here is to read n lines of input until you reach EOF, then number and print all n lines of content.
Hint : You can use Java's Scanner.hasNext() method, It is helpful for this problem.
Input Format
you have to read some unknown n lines of input from stdin(System.in) until you reach EOF, each line of input contains a non-empty String.
Output Format
You have to print the line number for each line, followed by a single space, and then the line content received as input.
Sample Input
Hello world
I am a file
Read me until end-of-file.
Sample Output
1 Hello world
2 I am a file
3 Read me until end-of-file.
Solution
import java.util.Scanner;
Learn more....
Learn Our best courses | JavaInDepth24 | Simplifying the skills Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops
04/09/2022
Learn Our best courses | JavaInDepth24 | Simplifying the skills Object-orientation is a perspective or way of thinking in terms of object on the basis of this thinking a programming model is devised by the name oops
Click here to claim your Sponsored Listing.
Category
Contact the school
Telephone
Website
Address
Nirman Vihar
Delhi
110092