Question
While the file has more data in it: - Read a line of data from the file and store it in a String. Each line
While the file has more data in it: - Read a line of data from the file and store it in a String. Each line in the file contains the bowler's name and three game scores. The line has the format:
lastname, firstname score score score
There is only one space between values. Extract the scores from the String and store them in 3 separate variables. JAVA
This is my code so far. I will attach a file example below my code as an example of what might be on the file. I must be able to extract as many strings that are present in the file, as in data may be added or subtracted.
Example of file data:
import java.util.*; import java.io.*; public class lab5 public static void main (String[] args) throws IOException { String fileName; String inputLine; int lineCount 0; scanner scan new Scanner(System.in); System.out.println("Enter file name: "); fileNamescan.nextLine (); Scanner filesc an = new Scanner (new File(fileName)); while (fileScan.hasNext() inputLine fileScan.nextLine(); //print the line we just got from the file System.out.println(inputLine); //count the input line inecount++ /of while file scan //main //class
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