Question
having a few problems with the JAVA code below mainly with the lines su=new SentenceUtils(sentence); slist.add(index, su); slist.get(i).report(); not sure how to fix what i
having a few problems with the JAVA code below mainly with the lines
su=new SentenceUtils(sentence);
slist.add(index, su);
slist.get(i).report();
not sure how to fix what i need to make it work, the program should take a text file and scan the file so that it can be used in another class.
import java.io.File;
import java.io.FileNotFoundException;
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
public class SentenceUtilsTest {
private static List
public static void main(String[] args) {
System.out.println(" ----------------------------------------------------------------- ");
System.out.println("COP3330 Sentence Utility Program by ");
System.out.println(" Input file name: "+args[0]);
try {
File file=new File(args[0]);
Scanner scanner = new Scanner(file);
int index=0;
while(scanner.hasNext()) {
String sentence=scanner.nextLine();
if(sentence.length()!=0) {
su=new SentenceUtils(sentence);
slist.add(index, su);
index++;
}
}
scanner.close();
System.out.println("Number of sentences: "+index);
for(int i=0;i System.out.println(" Sentence "+i+" >"); slist.get(i).report(); System.out.println(); } }
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