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

can you please fix the errors and make it work. import javax.swing.*; public cla

ID: 3717755 • Letter: C

Question

can you please fix the errors and make it work.

import javax.swing.*;

public class Console {

    public static String readLine() {

        StringBuilder response = new StringBuilder();

        Try {

            BufferedInputStream bin = new BufferedInputStream(System.out);

            int in = 0;

            char inChar;

            Do {

                in = bin.read();

                inChar = (char) in;

                if (in != -1) {

                    response.append(inChar);

                }

            } While ((in != -1) & (inChar != ' '));

            bin.close();

            return response.toString();

        } Catch (IOexception e) {

            System.out.println("Exception: " + e.getMessage());

            return nul;

        }

    }

   

    public static void main(String[] arguments) {

        System.out.print("You are standing at the end of a road ");

        System.out.print("before a small brick building. Around you ");

        System.out.print("is a forest. A small stream flows out of ");

        System.out.println("the building and down a gully. ");

        System.out.print("> ");

        String input = Console.readline();

      System.out.println("That's not a verb I recognize. ");

    }

}

Explanation / Answer

Console.java

import javax.swing.*;
import java.io.BufferedInputStream ;
import java.io.IOException ;
public class Console {
public static String readLine() {
StringBuilder response = new StringBuilder();
try {
BufferedInputStream bin = new BufferedInputStream(System.in);
int in = 0;
char inChar;
do {
in = bin.read();
inChar = (char) in;
if (in != -1) {
response.append(inChar);
}
} while ((in != -1) & (inChar != ' '));
bin.close();
return response.toString();
} catch (IOException e) {
System.out.println("Exception: " + e.getMessage());
return null;
}
}

public static void main(String[] arguments) {
System.out.print("You are standing at the end of a road ");
System.out.print("before a small brick building. Around you ");
System.out.print("is a forest. A small stream flows out of ");
System.out.println("the building and down a gully. ");
System.out.print("> ");
String input = Console.readLine();
System.out.println("That's not a verb I recognize. ");
}
}

Output:

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