Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Design and implement a program that counts the number of integer values in a tex

ID: 3640753 • Letter: D

Question

Design and implement a program that counts the number of integer values in a text
input file. Produce a table listing the values you identify as integers from the input file.
23,24.5,21,5,78.88,10,480.453,18,92,8,81,210.419,51,8,4,0,8,98.85,8,11,813

(What i have so far) If you can help me get into the right direction then that would be great!

import java.util.Scanner;
import java.io.*;
public class countinteger {
public static void main (String args[]) throws IOException
{

// Reads text from a file and prints their path
//components

String file;
Scanner filescan, each;
filescan = new Scanner (new File ("numbers.docx"));
//Read and process each line of the file
while (filescan.hasNext())
{
file = filescan.nextLine();
System.out.println ("File: " + file);
each = new Scanner (file);
each.useDelimiter ("/");
//Prints each part of the file
while (filescan.hasNext()){
System.out.println(" " + filescan.next());
System.out.println();

System.out.println("Index Value");
int wes[]=
for (int counter=0;counter<wes.length;counter++){
System.out.println(counter + " " + wes[counter]);

}
}
}
}

Explanation / Answer

import java.util.*; import java.io.*; import java.util.ArrayList; public class countinteger { public static void main(String[] args) throws FileNotFoundException { FileInputStream fsStream = new FileInputStream("C:\users\v-mattkn\desktop umbers.txt"); // file input stream DataInputStream in = new DataInputStream(fsStream); // data input stream BufferedReader br = new BufferedReader(new InputStreamReader(in)); // buffered reader object String line = null; // our line of input List ints = new ArrayList(); // the list of integers try { // try while((line = br.readLine()) != null) // while there is data in the file { String[] tokens = line.split(","); // split the line by comma and dump to array for(int i = 0; i
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote