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

Debugging Assignment Debug by fixing the errors you find in the program below. F

ID: 3883332 • Letter: D

Question

Debugging Assignment

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

(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");

    }

}}     

CORRECTED CODE:

LIST OF PROBLEMS FIXED:

Explanation / Answer

package syemmetric;

import java.net.MalformedURLException;

import java.util.Scanner;

public class Gettysburg {

public static void main(String[] args) {

String URLString = "http://cs.armstrong.edu/liang/Lincoln.txt";

int count = 0;

try {

java.net.URL url = new java.net.URL(URLString);

count = 0;

try (Scanner input = new Scanner(url.openStream())){

while (input.hasNext()) {

String Word = input.next();

if (Word.trim().length() > 0)

count += 1;

}

}   

}

catch (MalformedURLException ex) {

System.out.println("Invalid URL");

}

catch (java.io.IOException ex) {

System.out.println("IO Errors: no such file");

}

System.out.println("The number of words is " + count);

}

}

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