Question: Write an if-else statement that prints Goodbye if userString is Quit, else prints Hello. End with newline. import java.util.Scanner; public class DetectWord {
Write an if-else statement that prints "Goodbye" if userString is "Quit", else prints "Hello". End with newline.
import java.util.Scanner;
public class DetectWord {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userString;
userString = scnr.next();
/* Your solution goes here */
}
}
Step by Step Solution
3.43 Rating (153 Votes )
There are 3 Steps involved in it
You can achieve this by adding an ifelse statement in ... View full answer
Get step-by-step solutions from verified subject matter experts
