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
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