Print Username Program java Solution

Print Username


Jeffy, who is going to complete the higher education this year needs to create a simple application that accepts the name of a person and welcomes them with a message along with their name. She wants to read the data using the class “Scanner”. Implement this scenario using java.

Sample Input 1:

Enter the name:


Sample Output 1:

Welcome Johnson.

Sample Input 2:

Enter the name:

Stain Polson

Sample Output 2:

Welcome Stain Polson.

Code :-

import java.util.Scanner;
public class Username
    public static void main (String[] args) {
        Scanner sc=new Scanner(;
        System.out.println("Enter the name:");
        String name=sc.nextLine();
        System.out.println("Welcome "+name+".");

Leave a Comment

Scroll to Top
Scroll to Top