Java Print Username Program

Print Username

Question:-

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:

Johson

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.in);
        System.out.println("Enter the name:");
        String name=sc.nextLine();
        System.out.println("Welcome "+name+".");
    }
}

Recommended:-

  1. Bill Generation
  2. Spell Check
  3. Highest Placement
  4. Convert Numbers into Months
  5. Find Season

Leave a Comment

Your email address will not be published. Required fields are marked *