Need Java Help - Prompting User for Input
Posted: Tue Sep 11, 2007 4:20 am
I've taken a Comp Sci course this semester which covers Java. While we haven't started to learn the actual code and syntax, I decided to jump ahead. I have a little experience with C++ and Java from Comp Sci from HS, but it's been a while so everything is a little bit hazy so bear with me.
What I want to do is simple--prompt the user to enter an integer (or String then convert it to an integer). Then store the input in a variable. This is what I have....if there is better way to do this then by all means...I'm open ears
I get the following error:
I've searched on Google and attempted to look up for answer on why this is happening to no avail. Everything seems right, why am I getting an error? 
What I want to do is simple--prompt the user to enter an integer (or String then convert it to an integer). Then store the input in a variable. This is what I have....if there is better way to do this then by all means...I'm open ears
Code: Select all
import java.io.*;
import java.util.*;
public class problem1
{
public static void main (String[] args)
{
InputStreamReader stdin = new InputStreamReader(System.in);
BufferedReader console = new BufferedReader(stdin);
System.out.println("Enter a number");
String input = stdin.readLine();
int number = Integer.parseInt(input);
System.out.println(number);
}
}
Code: Select all
C:\Java>javac problem1.java
problem1.java:12: cannot find symbol
symbol : method readLine()
location: class java.io.InputStreamReader
String input = stdin.readLine();
^
1 error
