In Java Write a program that prompts the user for a name (any String value would work for testing), and print a hello message to the console with the input string after hello. (if the user typed 'class' then the console will display 'Hello class').

Respuesta :

Answer:

// program in java.

// package

import java.util.*;

// class definition

class Main

{

// main method of the class

public static void main (String[] args) throws java.lang.Exception

{

   try{

    // object to read input

Scanner scr=new Scanner(System.in);

 // ask to enter the name

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

 // read name

String name=scr.nextLine();

 // print the hello message

System.out.println("Hello "+name);

   }catch(Exception ex){

       return;}

}

}

Explanation:

Create a Scanner object to read name from user.Read name from user and assign it to variable "y_name".Then print the message Hello followed by the name.

Output:

Enter your name:Krish                                                                                                      

Hello Krish

Answer:

GIVE ME BRAINLIEST OR DIE!!

Explanation:

ACCESS MORE