SHARE
TWEET

Untitled

advictoriam Jan 15th, 2019 58 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class ReplaceCheck
  2. {
  3.    /**
  4.       A method to replace letters as follows:
  5.       the letter e becomes 3, the letter i becomes 1,
  6.       the letter l becomes 7, and the letter o becomes 0.
  7.       @param str a string
  8.       @return the string with the characters replaced
  9.    */
  10.    public static String replace(String str)
  11.    {
  12.       String result = "";
  13.       for(int i = 0; i < str.length(); i++)
  14.       {
  15.          switch(str.charAt(i))
  16.          {
  17.          case 'e':
  18.             result += '3';
  19.             break;
  20.          case 'i':
  21.             result += '1';
  22.             break;
  23.          case 'l':
  24.             result += '7';
  25.             break;
  26.          case 'o':
  27.             result += '0';
  28.             break;
  29.          default:
  30.             result += str.charAt(i);
  31.             break;
  32.          }
  33.       }
  34.       return result;
  35.    }
  36. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top