Question: data.txt 1 2 3 4 5 6 7 8 9 10 11 12 13 LineCount.java /** This is a simple program to count the lines

data.txt

1
2
3
4
5
6
7
8
9
10
11
12
13


LineCount.java

/**
This is a simple program to count the lines in a data file

*/
import javax.swing.* ;
import java.util.* ;
import java.io.* ;

public class LineCount
{
public static void main(String[] args)
{
//-----------Start below here. To do: approximate lines of code = 10
// Use a try{...}catch(){...} block and open a file "data.txt" using the File class.
// Create a Scanner object and pass in the File reference. Read the lines one at a time from the file
// and count them. Print "Number of lines: " followed by the line count


//-----------------End here. Please do not remove this comment. Reminder: no changes outside the todo regions.
System.out.println("Expected:Number of lines: 13");
}
}


Please have the expected output screenshotted and confirm that your code is formatted appropriately!

Step by Step Solution

3.41 Rating (170 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

This is a simple program to count the lines in a data file import javaxswing import jav... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!