Hey guys please help me out. This is homework by the way so please don't spoon feed me code but instead give me some advice on what to do. My goal is to make a program that lets the user change a word in a string. First it prompts the user to enter a string then prompts what word to look for then prompts another for what word you want to use to replace the word you looked for.
This is what I have so far.

i
Code:
mport java.util.Scanner;
public class replacement {


		int pos = 0;
		
		int lengther = 0;
		
		String replacer = new String(); // placeholder for the string that is replacing another string
		
		String replacee = new String();
		
		String line1 = new String();
		
		String line2 = new String();
	
		Scanner checker = new Scanner(System.in); // new object 
		
		System.out.print("Enter your sentence: ");
		line1 = checker.nextLine();
		
		System.out.print("What word do you want to look for?: "); // asks what word you want to scan
		replacee = checker.nextLine();
		
		System.out.print("What word do you want to use?: "); // asks what word do you want to use to replace the word you looked for
		replacer = checker.nextLine();
		

		while (pos >=0){ // stops at neg 1
			pos = line1.indexOf(replacee); // gets position of word the user is looking for
			
			if (pos >=0){ // start if
				line2 = line1.substring(0,pos);
				
				line2 = line2 + replacer;
				
				
				
				
				
			}// end if
			
	
			
			
			
		}// end loop
		
		
		
		
		
		
	
		
		
		
		
	}// end class

}// end main
What the problem is that this will partly work. It will replace one instance of the word the user inputs but after that it cuts everything else off. Also I know I can easily do this with the replace method but that is not what the teacher wants. It MUST be a while loop because that is what we as a class are focusing on right now. Any help is appreciated