/ assign1 / Greeting.java
Greeting.java
 1  /*
 2   * SPDX-FileCopyrightText: 2024 Jonas Smedegaard <dr@jones.dk
 3   *
 4   * SPDX-License-Identifier: GPL-3.0-or-later
 5   */
 6  
 7  import java.util.Scanner; // leave parsing complexities to a common class.
 8  
 9  public class Greeting {
10  	public static void main(String[] args) {
11  
12  		// instantiate object for scanning input data
13  		Scanner in = new Scanner(System.in);
14  
15  		// provide a prompt
16  		System.out.print("What is your name? ");
17  
18  		// capture input as variable before emitting, for eventual later reuse
19  		String name = in.nextLine();
20  		// 
21  		System.out.printf("Nice to meet you, %s!\n", name);
22  	}
23  }