11. Write a Java program to accept your first name and second name and join both the name to form a full
name.
Ex.
Input: First Name: James
Second Name: Gosling
Output: Full Name: James Gosling
please send me answer within 5minutes.please don't give unwanted answers.
Answers
Answer:
import java.util.*;
class FullName
{
public void main()
{
Scanner sc = new Scanner (System.in);
System.out.println("Enter First Name: ");
String str = sc.nextLine();
System.out.println("Enter Second Name: ");
String str1 = sc.nextLine();
System.out.println("Full Name: " + str + " " + str1);
}
}
I hope you got your answer... For any query do comment I will try to solve your answer...
Thank You.
Answer:
import java.util.Scanner;
public class Name{
public static void main(String []args){
Scanner myObj = new Scanner(System.in); // Create a Scanner object
System.out.println("Input First Name:");
String firstName = myObj.nextLine(); // Reads firstName
System.out.println("Input Second Name:");
String secondName = myObj.nextLine(); // Reads secondName
System.out.println("Full Name: " + firstName + " " + secondName); // Outputs FullName input
}
}