Java BufferedReader console read number input

Description

Java BufferedReader console read number input

import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

  public static void main(String[] args) throws Exception {
    BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
    String input = reader.readLine();

    double number = Double.parseDouble(input);

    System.out.println(input + ":" + Math.sqrt(number));

    reader.close();/*from  ww  w  .  ja  v a 2  s .c om*/
  }
}



PreviousNext

Related