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

 

orion.a.smith@gmail.com apcsa-loops > apcsaChatbotsRearrangeStartsIAm
prev  |  next  |  chance

Given an input String, first decide if the String starts with "I am ", like "I am hungry". If it does not start with "I am ", return "I don't understand". If it does start with "I am ", 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.

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

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

public String apcsaChatbotsRearrangeStartsIAm(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