about | help | code help+videos | done | prefs |
apcsaChatbotsPunctuatedWord
Given an input String, determine whether any of the words end with a comma or period. Note that what this means is that the character before the comma or period is a letter (which you can check using Character.isLetter(str.charAt(index)), returning true or false), since some of the inputs will either have no commas and no periods, or will have them in other locations. A word may have all sorts of things AFTER the comma or period. So long as you find a comma or period with a letter before it, return true. HINT: it's probably easiest to use a for loop on this problem, so that when you find a period or comma, you then look before that character for a letter. CHALLENGE: Solve in one statement. Probably requires regular expressions.apcsaChatbotsPunctuatedWord("Hello world") → false apcsaChatbotsPunctuatedWord("Hello, world") → true apcsaChatbotsPunctuatedWord("Hi. How are you?") → true ...Save, Compile, Run (ctrl-enter) |
Progress graphs:
Your progress graph for this problem
Random user progress graph for this problem
Random Epic Progress Graph
Difficulty: 210
Copyright Nick Parlante 2017 - privacy