/* * Lab 1. Practice writing a simple Java program * with basic I/O and conditional logic * * This is one possible solution to this program. * * name: CS 112 Course Staff */ import java.util.*; public class Greetings { public static void main(String[] args) { // Declare a reference to an instance of the Scanner class. // This creates the necessary connection to the keyboard // as our input device. Scanner scan = new Scanner(System.in); System.out.print("\nPlease enter your first name: "); String name = scan.next(); System.out.println("Hello " + name + ", Welcome to CS112!!!"); System.out.print("How old are you " + name + "? "); int age = scan.nextInt(); System.out.println( "WOW" ); // Once you are done with user input you can close the connection // to the Scanner. scan.close(); } // main }