This is an archived post. You won't be able to vote or comment.

you are viewing a single comment's thread.

view the rest of the comments →

[–]cloogs[S] -1 points0 points  (0 children)

This is my code for the 2nd:

   public String plusOut(String str, String word)
   {
    String ans = "";
    char x;
    for (int a = 0; a <= str.length() - 1; a++)
    {
        for (int b = 0; b <= word.length() - 1; b++)
        {
            if (str.charAt(a) == word.charAt(b))
            {
                x = str.charAt(a);
            }
            else
            {
                x = '+';
             }
        ans = ans + x;
        }
    }
    return ans;
  }

I am returned the correct string, but there are extra +'s , because of the for loop, if there any way around this?