Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 slist = new ArrayList();

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2010 Barcelona Spain September 2010 Proceedings Part 3 Lnai 6323

Authors: Jose L. Balcazar ,Francesco Bonchi ,Aristides Gionis ,Michele Sebag

2010th Edition

3642159389, 978-3642159381

More Books

Students also viewed these Databases questions

Question

Brief the importance of span of control and its concepts.

Answered: 1 week ago

Question

What is meant by decentralisation?

Answered: 1 week ago

Question

Write down the Limitation of Beer - Lamberts law?

Answered: 1 week ago

Question

c. What were you expected to do when you grew up?

Answered: 1 week ago

Question

d. How were you expected to contribute to family life?

Answered: 1 week ago

Question

e. What do you know about your ethnic background?

Answered: 1 week ago