Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 10Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started