Return string results arent correct
<p>This is my code, i want users to enter a word or a phrase, then the user can remove all characters, remove a single character, replace a character with another one and reverse characters.</p>

<p>Each individual function works by itself, but when i put it in the while loop the string i print out is the same as the user's input.</p>

<p>Basically the functions that is within the string didn't work. I don't know what is wrong with my code.</p>

<p>The loop kinda messed me up, if someone can test the code and that would be really awesome!    </p>

<pre><code>import java.util.Scanner;

public class StringFun {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int counter;
        String str, str1;
        boolean play=true;

        System.out.println("Enter the string to be manipulated:");
        str=scan.nextLine();
        while(play==true){

            System.out.println("Enter your command (quit, print reverse, replace all, replace single, remove");
            str1= scan.nextLine();

            if(str1.equalsIgnoreCase("print reverse"))
            {

                String reverse = "";
                Scanner in = new Scanner(System.in);

                System.out.println("Enter a string to reverse");
                String s=scan.nextLine().trim();

                int length = s.length();

                for ( int i = length - 1 ; i &gt;= 0 ; i-- )
                    reverse = reverse + s.charAt(i);
            }

            else if(str1.equalsIgnoreCase("replace all"))
            {
                System.out.println("Enter the character to replace");
                String s=scan.nextLine().trim();
                s=str.substring(0,1);

                System.out.println("Enter the new character");
                String r=scan.nextLine().trim();
                r=str.substring(0,1);

                str=str.replace(s, r);

            }
            else if(str1.equalsIgnoreCase("replace single"))
            {
                System.out.println("Enter the character to replace");
                String s=scan.nextLine().trim();
                s=str.substring(0,1);

                System.out.println("Enter the new character");
                String r=scan.nextLine().trim();
                r=str.substring(0,1);

                System.out.print("Which "+ s+ " do you want to replace?");
                int index=scan.nextInt();

                for (int i =0; i&lt;str.length();i++){
                    if(str.substring(i,i+1).equalsIgnoreCase(s))
                        index--;
                    if(index==0)
                        str=str.substring(0,i)+r+str.substring(i+1,str.length());
                }

            }
            else if(str1.equalsIgnoreCase("remove"))
            {
                System.out.println("Enter the character to remove");
                String s=scan.nextLine().trim();
                s=str.substring(0,1);

                str.replace(s,"");
            }

            else if(str.equalsIgnoreCase("quit"))
                System.exit(0);
            else
                System.out.println("Please enter a valid command");

            System.out.println(str);

        }
    }
}
</code></pre>