Following is the code, I have written to get two inputs from user. But when I run the program, It takes only one input and generate other by itself and calculate the wrong v
System.in
is an InputStream
- read()
reads exactly one byte. Your direct input is more than one byte and so both values are directly read within the first input.
Use a Scanner instead (with System.in as Input):
Scanner sc = new Scanner(System.in);
int i = sc.nextInt();
More Examples: http://docs.oracle.com/javase/1.5.0/docs/api/java/util/Scanner.html