Writa a java program that take input as aperson name in the format of first middle last name and then print it in the form last first and middle,where in the middle name first character is capital letter||EasyCoding45

In this tutorial, we are going to learn how we can Write a java program that take input as a person name in the format of first ,middle and last name and then print it in the form of last, first and middle ,where in the middle name first character will be capital letter.


Below is the Program :--


import java.util.*;

class person

{

String fname,mname,lname;

int len;

void accept()

{

System.out.println("Enter First Name :");

Scanner s=new Scanner(System.in);

fname=s.next();

System.out.println("Enter Middle Name :");

mname=s.next();

System.out.println("Enter Last Name :");

lname=s.next();

len=mname.length();

String f=mname.substring(0,1);

String l=mname.substring(1,len);

f=f.toUpperCase();

mname=f+l;

}

void display()

{

System.out.println("Last Name :"+lname);

System.out.println("First Name :"+fname);

System.out.println("Middle Name :"+mname);

}

public static void main(String a[])

{

person p=new person();

p.accept();

p.display();

}

}


Output :--





                                                    Thank You💚                                                            

Comments