I am trying to figure out how to use character wrapping to mutate a string based on user input. If string is 'Bob loves to build building' and user enters 'b' I have to make the out put change both the lower case and upper case letter bs.
This is what it must add on to:
System.out.print("\nWhat character would you like to replace?");
String letter = input.nextLine();
System.out.print("What character would you like to replace "+letter+" with?");
String exchange = input.nextLine();
Im not sure what you dont get about the previous replies but this ties them to your code.
A simplistic approach would be:
EDIT: Added toLowerCase() as per suggestion below.
how about:
EDIT: myString is the string you want to replace the letter in.
letter is taken from your code, it is the letter to be replaced.
exchange is also taken from your code, it is the string that letter is to be replace with.
Of course you would need to do this again for the upper case letter and lower case so it would be:
In order to cover the case where the entered letter is either lower or uppercase.
Check
replace
method:For more details see [
String#replace
](http://docs.oracle.com/javase/6/docs/api/java/lang/String.html#replace(char, char))EDIT:
Does that solve your problem?