The following program is to concatenate 3 strings and I have used Scanner class for getting the user input of 3 strings. Can you all please let me know is I can improve this or is it perfect ?
import java.util.Scanner;
class GetInputFromUser
{
public static void main(String args[])
{
String s;
String t;
String q;
Scanner in = new Scanner(System.in);
System.out.print("\n Enter Your First Name : ");
s = in.nextLine();
System.out.print("\n Enter Your Middle Name : ");
t = in.nextLine();
System.out.print("\n Enter Your Last Name : ");
q = in.nextLine();
String fullName = s.concat(t);
String name = fullName.concat(q);
System.out.println("\n Your Full Name is : "+ name+"."+"\n");
}
}
Thank you for reading.
No comments:
Post a Comment