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

 

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

Write a method that uses a string called 'swap', which is always exactly two characters long, to determine which to symbols to swap in the string 'str'. For example, if 'str' is "A man, a plan a canal, Panama." and 'swap' is "an" the resulting string would be "A mna, n plna n cnanl, Pnanmn." because each "a" gets replaced with "n" and each "n" gets replaced with "a". Note that the replacement is case sensitive, which is why the "A" was not replaced. Look at the test data for additional examples.


jan30_2020_APP1SLHL_swapLetters("", "az") → ""
jan30_2020_APP1SLHL_swapLetters("bannanna, orange, grape, strawberry, plum", "rb") → "rannanna, obange, gbape, stbawrebby, plum"
jan30_2020_APP1SLHL_swapLetters("My desk has lots of stuff on it.", "do") → "My oesk has ldts df stuff dn it."

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

public String jan30_2020_APP1SLHL_swapLetters(String str, String swap) { }

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: 290

Copyright Nick Parlante 2017 - privacy