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

Complete the code in the ExTestDrive.java file by replacing the commented-out bl

ID: 3643569 • Letter: C

Question

Complete the code in the ExTestDrive.java file by replacing the commented-out blank lines with
some or all of the code snippets at the top of the file. Your code should produce the following output
when run:
input: yes" output: thaws
input: no" output: throws


// Snippet pool
//
// System.out.print("a");
// System.out.print("o");
// System.out.print("r");
// System.out.print("t");
// System.out.println("ws");
// doRisky(test);
// throw new MyEx();
// yes.equals(t)
//



class MyEx extends Exception { }

public class ExTestDrive {
public static void main (String [] args) {
String test = (new Scanner(System.in)).next();

try {
// ___________________
// ___________________
// ___________________
}
catch (MyEx e) { // ______________________ }
// _____________________
}

static void doRisky(String t) throws MyEx {
System.out.print("h");

if (//______________________) //___________________

// ____________________
}
}

Explanation / Answer

please rate


class MyEx extends Exception { }

public class ExTestDrive {
public static void main (String [] args) {
String test = (new Scanner(System.in)).next();

try {
System.out.print("t");
doRisky(test);
System.out.print("o");
}
catch (MyEx e) {System.out.print("a"); }
System.out.println("ws");
}

static void doRisky(String t) throws MyEx {
System.out.print("h");

if (yes.equals(t)) throw new MyEx();

System.out.print("o");
}
}