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

 

jebbert@volusia.k12.fl.us > hobbit1
prev  |  next  |  chance

J.R.R. Tolkien has decider to re-write The Hobbit. He needs your help! He has decided to replace the "ring" with the "pacifier". Write a method that accepts an input string and returns a new version of that string with each occurance of the word "ring" replaced with the word "pacifier". You may assume that the input string will have no capital letters. The only problem is that Mr. Tolkien will only let you use four string methods: length, substring, equals, and charAt. So those are the only string methods you can use in your program. You can use string operations such as assignments and concatenation, but no other string methods! Of course you can use conditionals and loops as much as you want.


hobbit1("the one ring! wow!") → "the one pacifier! wow!"
hobbit1("bilbo reached for the ring and slipping it on, disappeared") → "bilbo reached for the pacifier and slipping it on, disappeared"
hobbit1("for whom the bell rings.") → "for whom the bell pacifiers."

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

public String hobbit1(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: 320

Copyright Nick Parlante 2017 - privacy