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

1 Expert Approved Answer
Step: 1 Unlock

You can achieve this by adding an ifelse statement in ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!