Skip to content

Instantly share code, notes, and snippets.

@michaelee
Created April 3, 2009 18:36
Show Gist options
  • Save michaelee/89886 to your computer and use it in GitHub Desktop.
Save michaelee/89886 to your computer and use it in GitHub Desktop.
import java.util.*;
public class InputTest {
public static void main (String [] args) {
Scanner scanner = new Scanner(System.in);
String s;
int i;
double d;
System.out.println("Enter a string:");
s = scanner.nextLine();
System.out.format("You entered '%s'\n", s);
System.out.println("Enter an integer:");
i = scanner.nextInt();
System.out.format("You entered '%d'\n", i);
System.out.println("Enter a floating point number:");
d = scanner.nextDouble();
System.out.format("You entered '%f'\n", d);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment