Question: Here is my code: please help Write a Java program that prompts the user for an inspirational message using a (single) Scanner object. Display the

Here is my code:

please help
Write a Java program that prompts the user for an inspirational message using a (single) Scanner object. Display the message. Example: Please enter your favorite inspirational message: Do or do not, there is no try. You entered: Do or do not, there is no try. Console Shell 1 3 Main.java import java.util.*; 2 public class Scanner1 { public static void main(String[] args) { Scanner sc = new Scanner(System.in); System.out.print("Please enter your favorite inspirational message: "); // Scanner object to read single line String S = sc.nextLine(); System.out.println("You entered: "+s); } } > javac -classpath .:/run_dir/junit-4 Q x 1 r:target/dependency/* -d . Main.java Main.java:2: error: class Scannerl is publi c, should be declared in a file named Scann eri.java public class Scannerl { 4 5 6 7 1 error compiler exit status 1 8 9 10
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
