Question: In this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program below. Fix the code, and paste
In this assignment you will demonstrate your knowledge of debugging by fixing the errors you find in the program below. Fix the code, and paste it in this document, along with the list of the problems you fixed. This example is based on a program which counts the words in the Gettysburg Address.
import java.util.Scanner;
public class Gettysburg {
public String void main(String[] args) {
String URLString = "http://cs.armstrong.edu/liang/Lincoln.txt';
try {
java.net.URL url = new java.net.URL(URLString)
int count = 0;
try (Scanner input = new Scanner(url.openStream()))
while (input.hasNext()) {
String Word = input.next();
if (word.trimm().lemgth() > 0)
count += 1;
}
}
}
System.out.println("The number of words is " + count);
}
catch (java.net.MalformedUNLException ex) {
System.out.print1n("Invalid URL");
}
catch (java.io.IOException ex) {
System.println("IO Errors: no such file");
}
}}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
