Answer:
The program to this question as follows:
Program:
//defining package
import java.util.*; //import package for user input
public class Name //defining class Name
{
public static void main (String ar []) //defining main method
{
String First_Name,Last_Name; //defining variables
Scanner obc = new Scanner(System.in); //creating Scanner class object
System.out.print("Enter your full name: "); //message
First_Name = obc.next(); //taking input
Last_Name = obc.next(); //taking input
System.out.println(Last_Name +" , "+ First_Name); //print value
}
}
Output:
Enter your full name: data base
base , data
Explanation:
The description of the above java program as follows:
- A package is imported for user input in the first line of the program, then a class is defined, that is "Name", in this class two string variable is declared, that is "First_Name and Last_Name".
- In the next step, a scanner class object is created, which is "obc", which is used to take user input in this variable that is declared above.
- Then a print function is used to print the user input values, in printing time the last name is printed first that is separated by a comma then print the value of first name.