import java.awt.*;
// Need this import for reading data:
import java.io.*;
// reading data in a Java application
public class ReadingData1 {
public static void main (String [] args) throws IOException {
// Create a buffered reader
BufferedReader in = new BufferedReader(
new InputStreamReader(System.in));
// string for storing a line of input
String line;
// Read one integer
// prompt the user:
System.out.print("Please enter a number: ");
// read a line of input:
line = in.readLine();
// check what the input is:
System.out.println("The input is: " + line);
// extract the integer from the entered data:
double n = Double.parseDouble(line);
// print out the value of n:
System.out.println("n = " + n);
// increment n by 1.5
n = n + 1.5;
// print out the result:
System.out.println("n = " + n);
}
}
This is an example from CSci 1211 course.