67 216
Assignments Done
99,2%
Successfully Done
In November 2018

Answer to Question #33431 in Java | JSP | JSF for Jimbo

Question #33431
Write a program ReplaceTester that encodes a string by replacing all letters "i" with "!" and all letters "s" with "$". Use the replace method. Demonstrate that you can correctly encode the string "Mississippi". Print both the actual and expected result.
Expert's answer
Source:

public class ReplaceTester {
public static void main(String[] args){
String input = "Missiissippi";
String result = input.replaceAll("i",
"!");
result = result.replaceAll("s",
"\$");
System.out.println("Expected result:
M!$$!!$$!pp!");
System.out.println("Actual result:
"+result);
}
}

Result:

Expected result: M!$$!!$$!pp!

Actual result: M!$$!!$$!pp!

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions