Problem
Write an if-else statement to describe an object. Print "Balloon" if isBalloon is true and isRed is false. Print "Red balloon" if isBalloon and isRed are both true. Print "Not a balloon" otherwise. End with newline. (Notes)
import java.util.Scanner;
public class RedBalloon {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
boolean isRed;
boolean isBalloon;
isRed = scnr.nextBoolean();
isBalloon = scnr.nextBoolean();
/* Your solution goes here */
}
}
I wrote:
import java.util.Scanner;
public class RedBalloon {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
boolean isRed;
boolean isBalloon;
isRed = scnr.nextBoolean();
isBalloon = scnr.nextBoolean();
/* Your solution goes here */
if(isBalloon&&isRed) {
System.out.println("Red balloon");
}else if(isBalloon) {
System.out.println("Balloon");
}else{
System.out.println("Not a balloon");
}
return;
}
}
What the assignment told me:
main.java:440: error: unreachable statement
zyAssertOutput("Not a balloonn", ^
main.java:456: error: unreachable statement '
zyAssertOutput("Balloonn", ^
main.java:472: error: unreachable statement
zyAssertOutput("Not a balloonn", ^
main.java:488: error: unreachable statement
zyAssertOutput("Red balloonn", ^ 4 errors