Computer Science 202
Introduction to Programming
Fall 2012, The College of Saint Rose
HelloYou BlueJ Project
Click here to download a BlueJ project for HelloYou.
Download file: HelloYou.vls
HelloYou Source Code
The Java source code for HelloYou is below. Click on a file name to download it.
/* * Example HelloYou * * Prompt for and read in the user's name, then greet the user with * a friendly message. * * Jim Teresco, The College of Saint Rose, CSC 202, Fall 2012 * * $Id: HelloYou.java 1893 2012-09-06 04:09:25Z terescoj $ */ // we need to tell Java that we intend to use one of the tools // in its API import java.util.Scanner; public class HelloYou { public static void main(String[] args) { // create a "scanner" that can read in what we type at // the command line Scanner input = new Scanner(System.in); // issue a "prompt" so someone running the program knows // that the system is expecting some keyboard input System.out.print("What is your name? "); // read in the next (and in our case, only) item typed in String name = input.next(); // take what was typed in and print a friendly greeting System.out.println("Hello, " + name); } }