Originally posted by Nigel Browne:
Please post your code and explain where you are stuck.
// Program to take in one line sentence as input then outputs the following If the sentence ends with a
// question mark and the input contains an even number of characters then output the word YES.
// If the sentence ends with a question mark and the input contains an odd number of characters
// output the word NO.
public class Sentence
{
public static void main(String[] args)
{
String sentence;
System.out.println("Please input a sentence with correct punctuation at the end of the sentence.");
sentence = SavitchIn.readLine();
if (sentence.equals("?"))
System.out.println("Yes");
else
System.out.println("No");
if (sentence.equals("!"))
System.out.println("Wow");
else
System.out.println("You always say " + sentence);
}
}