Write a program that reads a one-line sentence and displays the following responses:
?
and the input contains an even number of characters, display Yes
.?
and the input contains an odd number of characters, display No
.!
, display Wow
You always say
followed by the original sentence in quotes.Scanner kb = new Scanner(System.in);
String inputLine = kb.nextLine();
int stringLength = inputLine.length();
if (inputLine.charAt(stringLength - 1) == '?' && (stringLength % 2 == 0))
System.out.println("Yes");
else if (inputLine.charAt(stringLength - 1) == '?' && (stringLength % 2 == 1))
System.out.println("No");
else if (inputLine.charAt(stringLength - 1) == '!')
System.out.println("Wow");
else
System.out.println("You always say \"" + inputLine + "\"");