2.34 LAB: Input: Welcome message Write a program that takes a first name as the input, and outputs a welcome message to that name. Ex: If the input is: Pat the output is: Hello Pat, and welcome to CS Online!

Respuesta :

ijeggs

Answer:

import java.util.Scanner;

public class ANot {

   public static void main(String[] args) {

Scanner in = new Scanner(System.in);

       System.out.println("Please Enter your First Name");

       String name = in.next();

       System.out.println("Hello "+name+", and welcome to CS Online!");

   }

}

Explanation:

Using Java programming language. Firstly we imported the Scanner class needed to receive user input. Then we created a object of the Scanner class. The User is prompted for input with this statement;

System.out.println("Please Enter your First Name");

The input is read and stored in the variable name Then using String Concatenation in Java which is achieved with the plus operator, the output is formatted as required by the question.