Question: I am trying to replace the first instance of a letter with an inputted letter but it is only outputting the letter I input. inport

I am trying to replace the first instance of a letter with an inputted letter but it is only outputting the letter I input.

I am trying to replace the first instance of a letter withan inputted letter but it is only outputting the letter I input.

inport java.util.Scanner public class StringFun public static void main(String] args) Scanner keyboard new Scanner(Systen.in); String userInput; String userCommand; String replaceFirstStringold; String replaceLastStringoLd: String replaceFirststringNew String replaceLaststringNew: String isolateChar = ""; String replaceLetter=""; int userInputLength; String reverse = "reverse". String replaceFirst "replace first"; String replaceast = "replace last". String removeAl "remove all" String remove "remove" String quit "quit"; Systen.out.println("Enter the string to be manipulated"; userInput keyboard.nextLine); userInput Length = (userInput.length() -1 ); System.out.println("Enter your command (reverse, replace first, replace last, remove all, remove") userCommand = keyboard.next Line(); f (userCommand.equalsignoreCase(reverse)) for (userInputLengthuserInputLength; userInputLength > 1; userInputLength--) isolateChar isolateCharuserInput.charAt(userInputLength); System.out.println("The new sentence is: "isolateChar); if (userCommand.equalsIgnoreCase(replaceFirst)) System.out.println( "Enter the character to replace"; replaceFirstStringold keyboard.next); System.out.println("Enter the new character" replaceFirstStringNew keyboard.next for (int i=0; 1 userInputLength; 1++) if (userInput.charAt(i) replaceFirstStringold.charAt(8)) == replaceLetter = replaceLetter + replaceFirstStringNew.charAt(@); else replaceLetter replaceLetter + userInput. charAt(i); System.out.print( "The new sentence is: "replaceFirstStringNew); System.out.println) System.exit(e); Enter the string to be manipulated Gi Enter your command (reverse, replace first, replace last, remove all, remove replace first Enter the character to replace Enter the new character 0 The new sentence is: o

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!