Respuesta :
If you are using Java then the IF statement would be:
If(userSting == "Quit"){
System.out.println("Goodbye");
}
else
System.out.println("Hello");
The IF statement will check whether the users input is the word "Quit". If the word is indeed "Quit" then the program will output the word "Goodbye". The ELSE statement on the other hand will only be displayed if the user inputs any other string than "Quit". The program will then output the word "Hello" any other string or number is inputted by the user.
import java.util.Scanner;
public class DetectWord {
public static void main (String [] args) {
Scanner scnr = new Scanner(System.in);
String userString;
userString = scnr.next();
if(userString.equals("Quit")){
System.out.println("Goodbye");
}
else{
System.out.println("Hello");
}
}
}
This actually works for anything written and will provide the proper outcome for zybooks