Computer Science, asked by manju93314, 1 year ago

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 sswaraj04
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 Ranauk456
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]);

}}


Ranauk456: thanks
manju93314: I should say thanks
Ranauk456: okay say
Ranauk456: then welcome for you
Similar questions