Question
Unreachable statement???????
CSIT 111 home> 313: More string operations E zyBooks catalog Print Censored if userinput contains the word darn, else print userinput. End with newline Note: These activities may test code with different test values. This activity will perform three tests, with userinput of That darn cat, then with Dang, that was scary!, then with Im darning your socks.. See How to Use zyBooks . Also note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report Program end never reached The system doesnt print the test case that caused the reported message 1 import java.util. Scanner; 4 public s ing [1 args) String user fogut nostn (iString [I args) String userInput userInput That darn cat / Your solution goes here / 10if(userInput.indexof (darn) 1--1)0 13 else( System.out.println(userInput); 19 ) Run Failed to compile main.java:389: error: unreachable statement zyAssertoutput (Censoredin,
0 0
Add a comment Improve this question Transcribed image text
Answer #1

Hi,

An unreachable statement error means a compile-time error if a statement cannot be executed because it is unreachable.
But, here your code is pretty simple and doesn't have any such issue if you see closely, this is Zybooks issue, its testing code "assertEquals" that is testing the test cases is having an issue. Your code is CORRECT for the given question.


Thumbs up if this was helpful, otherwise let me know in comments

Add a comment
Know the answer?
Add Answer to:
Unreachable statement??????? CSIT 111 home> 313: More string operations E zyBooks catalog Print 'Censored if userinput...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Print 'Censored if userinput contains the word"darn', else print userinput End with newline. Ex iIf userinput...

    Print 'Censored if userinput contains the word"darn', else print userinput End with newline. Ex: if userinput is "That darn cat.:. then output is: Censored Ex: If userinput is Dang, that was scaryl", then output is: Dang, that was scary Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report Program end never reached The system doesn't print the test case that caused the reported message. import java.util.Scanner; public class Censoredwords {public static...

  • WRITE THIS IN JAVA!!!! Print "Censored" if userlnput contains the word "darn", else print userlnput. End...

    WRITE THIS IN JAVA!!!! Print "Censored" if userlnput contains the word "darn", else print userlnput. End with newline. Ex: If userlnput is "That darn cat.", then output is: Censored Ex: If userlnput is "Dang, that was scary!", then output is: Dang, that was scary! Note: If the submitted code has an out-of-range access, the system will stop running the code after a few seconds, and report "Program end never reached." The system doesn't print the test case that caused the...

  • Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin...

    Code is in C# Your instructor would like to thank to Marty Stepp and Hélène Martin at the University of Washington, Seattle, who originally wrote this assignment (for their CSE 142, in Java) This program focuses on classes and objects. Turn in two files named Birthday.cs and Date.cs. You will also need the support file Date.dll; it is contained in the starter project for this assignment. The assignment has two parts: a client program that uses Date objects, and a...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT