Im trying to write a java code for a homework problem in my intro java class but im having problems, frankly cause i dont know alot of loops and my text book doesnt help.
This is the problem:
The serperate myfile.txt has thisWrite a program that open the MyFile.txt and read from a file with these criteria.
1)-The program should display the first five lines of the file’s contents only.
2)-If the file contains less than five lines, it should display the file’s entire content. You must check for end of file and less than 6 lines on the loop iterations.
3)- your program should use loop to read the line by line of the file MyFile.txt.
and this is what the code is suppose to look like after you run it.I can still remember, at the end of that year, we sat for the last time in our circle together.
She played us her favorite song, "like a bridge over troubled water"
and quietly passed out a gift she had made for each of us.
She had made each of us a pottery heart with our name and the date on it on the back each read
"I believe in ME".We all cried including her.
She told us she would always remember US. We believed she would.
Java33.png
And this is what i have so far:
Java22.png
Can someone show me what needs to go next to complete the java script to show the first 5 lines of the text files? Im really at a road block with this.