This code is supposed to be able to read a users input and do any of the options in the menu choice, What Im I missing? Sample outputs are
Enter a sample text: We'll continue our quest in space.
You entered: We'll continue our quest in space. MENU c - Number of non-whitespace characters w - Number of words f - Find text r - Replace all !'s s - Shorten spaces q - Quit
Choose an option: c Number of non-whitespace characters: 6
import java.util.Scanner
public class AuthoringAssistant {
public static void main(String [] args) {
Scanner scnr = new Scanner(System.in);
String mainString = "";
System.out.println("Enter a sample text:");
mainString = scnr.nextLine();
System.out.print("You entered: ");
System.out.println(mainString);
return mainString;
}
public static void printMenu(){
Scanner scnr = new Scanner(System.in);
char menuChoice = '?';
String inputString="";
while(menuChoice != 'q'){
System.out.println("MENU");
System.out.println("c - Number of non-whitespace characters");
System.out.println("w - Number of words");
System.out.println("f - Find text");
System.out.println("r - Replace all !'s");
System.out.println("s - Shorten spaces");
System.out.println("q - Quit");
menuChoice = scnr.next().charAt(0);
if(menuChoice == 'c'){
getNumOfNonWSCharacters();
}else if(menuChoice == 'w'){
getNumOfWords();
}else if(menuChoice == 'f'){
findText();
}else if(menuChoice == 'r'){
replaceExclamation();
}else if(menuChoice == 's'){
shortenSpace();
}
}
return;
}
}