/* Joanne Houlahan 600.107 This demo program illustrates use of the Scanner class for input, which is available in Java versions >= 5.0 (not in lower versions). */ import java.util.*; // grab entire util package public class inputscan { public static void main (String[] args) { Scanner console = new Scanner(System.in); //"console" is just a variable int number; double real; char let; String word, line; System.out.println("enter integer, real, character, word and other stuff"); number = console.nextInt(); real = console.nextDouble(); let = console.next().charAt(0); word = console.next(); line = console.nextLine(); System.out.println(line + " " + number + " " + word + " " + real + " " + let); System.out.println(line + '\n' + number + "\n" + word + "\n" + real + "\n" + let); System.out.println("Printing \"in quotes\""); //the escape character System.out.println("Enter a double value:"); double doubleValue = console.nextDouble(); //Reads in the double, but not the new line character! // console.nextLine(); // this will "read" (skip) the end of line marker System.out.println("Now enter a string:"); String inputResponse = console.nextLine(); //Reads in the new line character that was left in the buffer System.out.println(inputResponse); word = "The End"; System.out.println(word); } }