ok so here is goes heres the question

Write a JAVA program that takes a one-line sentence as input and then outputs the following response: 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”. In all other cases, your program will output the string “You always say “ followed by the input string enclosed in quotes. Your output should all be on one line. Be sure to note that in the last case, your output must include quotation marks around the echoed input string. In all other cases, there are no quotes in the output.


i am completely lost ive looked in the text book for some tips to solving this problem and ive come up empty handed if anyone has any tips on approaching this problem it would be appreciated

Member Avatar for iamthwee

Find yourself a java string tutorial. That might be a good starting point?

  1. Write a program which is able retrive input from user and store it in string
  2. Look up method which will tell you the length of that string, length also will help to find if number of character is even or odd
  3. Look up method which is able to get you character from position i in the string and check if it is question mark
  4. Based on previous findings you can generate equivalent output
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.