id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

orion.a.smith@gmail.com hcs-chatbots > apcsaChatbotsRearrangeContainsIAm
prev  |  next  |  chance

Given an input String, first decide if the String contains "I am (something)", like "I think I am hungry". If it does not contain "I am (something)", return "I don't understand". Note that this problem is just like the previous one, except it's more flexible - "I am (something)" could occur anywhere in the input. If it does contain "I am (something)", return a response that includes part of the input in the form "Why are you (rest of input)?" If you are still confused, see the input/output test cases.


HINT: use substring to capture the rest of the input, which becomes part of the output.

apcsaChatbotsRearrangeContainsIAm("I am hungry") → "Why are you hungry?"
apcsaChatbotsRearrangeContainsIAm("I was hungry") → "I don't understand"
apcsaChatbotsRearrangeContainsIAm("What if I am hungry") → "Why are you hungry?"

...Save, Compile, Run (ctrl-enter)

public String apcsaChatbotsRearrangeContainsIAm(String str) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 210

Copyright Nick Parlante 2017 - privacy