Question: Below is my question Then this is my code in eclipse that i used and the output i got The question i have is that

Below is my question

Below is my question Then this is my code in eclipse thati used and the output i got The question i have is

Then this is my code in eclipse that i used and the output i got

that if i am right with my output and stuff. I havebeen seeing people use my code and get if anyone can helpThe question i have is that if i am right with my output and stuff. I have been seeing people use my code and get

i would be thankful for that. You cannot see it well but

if anyone can help i would be thankful for that. You cannot see it well but it show:

No of tokens that are numbers:6 No of tokens that are not numbers:7 Sum of the numbers: 12.6

my code when running on my laptop i get

No of tokens that are numbers:0 No of tokens that are not numbers:0 Sum of the numbers:0

just want to know what i am doing wrong

Task The task is to read the tokens from a file and print out three values: the number of tokens that are numbers (double s), the number of tokens that are not numbers, and the sum of the numbers For example, if this is the contents of the file being processed: 1 2 3 one two three Your program should print out: 6 7 12.6 and nothing else Assume that the name of the file is data.txt.In Eclipse, the file needs to be in the top directory of the project. To open a file, use a sequence of code like: Scanner in = null; try t in = new scanner (new File ("data.txt")); J catch (FileNotFoundException e) t System.err.println("failed to open data.txt"); System.exit(1); You will need import statements at the top of yourjava file in order to use the Scanner and File classes. import java.util.scanner; import java.io.File; After you are done processing the file, close it. in.close(); Reading all the tokens in a file can be done via a loop while (in.hasNext()) string token = in.next()

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock 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 Databases Questions!