Write a program in java to accept a name containing three words and display the surname first followed by the first and second name
Answers
Answered by
6
Answer:
import java.util.Scanner;
public class surname{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("input your name ");
String name= sc.nextLine();
String namearr[] = name.split(" ");
System.out.println(namearr[2]+" "+namearr[0]+" "+namearr[1]);
}}
Explanation:
manju93314:
thanks a lot
Answered by
6
import java.util.Scanner;
public class surname{
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("input your name ");
String name= sc.nextLine();
String namearr[] = name.split(" ");
System.out.println(namearr[2]+" "+namearr[0]+" "+namearr[1]);
}}
Similar questions
Math,
6 months ago
English,
6 months ago
CBSE BOARD XII,
1 year ago
Hindi,
1 year ago
Chemistry,
1 year ago