Answer:
// program in java.
import java.util.*;
// class definition
class Main
{// main method of the class
public static void main (String[] args) throws java.lang.Exception
{
try{
// object to read input
Scanner scr=new Scanner(System.in);
// ask to enter name
System.out.print("Enter Your name: ");
// read name from user
String NAME=scr.nextLine();
// print message
System.out.println("Greetings,"+NAME);
}catch(Exception ex){
return;}
}
}
Step-by-step explanation:
Read name from user with the help of scanner object and assign it to variable "NAME".Then print a Greetings message as "Greetings,NAME" where NAME will be replaced with user's input name.
Output:
Enter Your name: Rachel
Greetings,Rachel