Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

import java.util.Scanner; public class AuthoringAssistant { public static void m

ID: 3594136 • Letter: I

Question

import java.util.Scanner;

public class AuthoringAssistant {

public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
String userInput = sc.nextLine();
System.out.println("Enter a sample text: ");
System.out.println(userInput);

return printMenu;
}

public static printMenu(Character[] menu) {
Scanner in = new Scanner(System.in);
Character userChar = in.nextLine().charAt(0);
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");
System.out.println("Choose an option: ");

if (userChar == 'q') {
System.out.println("q");
System.out.println("Quit");
}
else if (userChar == 'w') {
System.out.println("w");
System.out.println("Number of words: ");
}
else if (userChar == 'f') {
System.out.println("f");
System.out.println("Find text: ");
}
else if (userChar == 'r') {
System.out.println("r");
System.out.println("Replace all !'s: ");
}
else if (userChar == 's') {
System.out.println("s");
System.out.println("Shorten spaces: ");
}
else if (userChar == 'c') {
System.out.println("c");
System.out.println("Number of non-whitespace characters: ");
}  
else {
System.out.println("Please select a valid character.");
}

return in.nextCharacter();
}
}

I am trying to run the code but I keep getting a error is anyone able to fix it to make the code run so it runs

it keeps giving me AuthoringAssistant.java:14: error: invalid method declaration; return type required public static printMenu(Character[] menu) {

Explanation / Answer

import java.util.Scanner;
public class AuthoringAssistant {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
System.out.println("Enter a sample text: ");
String userInput = sc.nextLine();
System.out.println(userInput);
sc.close();
printMenu();
}
public static void printMenu() {
Scanner in = new Scanner(System.in);
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");
System.out.println("Choose an option: ");
Character userChar = in.nextLine().charAt(0);
if (userChar == 'q') {
System.out.println("q");
System.out.println("Quit");
}
else if (userChar == 'w') {
System.out.println("w");
System.out.println("Number of words: ");
}
else if (userChar == 'f') {
System.out.println("f");
System.out.println("Find text: ");
}
else if (userChar == 'r') {
System.out.println("r");
System.out.println("Replace all !'s: ");
}
else if (userChar == 's') {
System.out.println("s");
System.out.println("Shorten spaces: ");
}
else if (userChar == 'c') {
System.out.println("c");
System.out.println("Number of non-whitespace characters: ");
}  
else {
System.out.println("Please select a valid character.");
}
}
}