Friday, 27 October 2023

Write a java program that asks the user name, and then greets the user by name. Before outputting the user's name, convert it to upper case letters. For example, if the user's name is Raj, then the program should respond "Hello, RAJ, nice to meet you!".- Core JavaSlip13

 Write a java program that asks the user name, and then greets the user by name. Before outputting the user's name, convert it to upper case letters. For example, if the user's name is Raj, then the program should respond "Hello, RAJ, nice to meet you!".

 

import java.util.Scanner;

import java.io.*;

public class GreetUser {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

 

        System.out.print("Enter your name: ");

        String userName = scanner.nextLine();

 

        // Convert the user's name to uppercase

        String upperCaseName = userName.toUpperCase();

 

        System.out.println("Hello, " + upperCaseName + ", nice to meet you!");

 

        scanner.close();

    }

}

 

 

C:\Program Files\Java\jdk-11.0.17\bin>javac GreetUser.java

 

C:\Program Files\Java\jdk-11.0.17\bin>java GreetUser

Enter your name: Raj

Hello, RAJ, nice to meet you!

 

C:\Program Files\Java\jdk-11.0.17\bin>