|
|
back to boardWhat's wrong with my program in Java? import java.math.RoundingMode; import java.text.DecimalFormat; import java.util.Scanner; public class Timus { public static void main(String[] args) { String regexp = "[\\n?\\s]+"; Scanner c = new Scanner(System.in); String data = c.nextLine(); String[] numbers = data.split(regexp); for (int i = numbers.length - 1; i >= 0; i--) { System.out.println(truncateSqrt(numbers[i])); } } private static String truncateSqrt(String s) { DecimalFormat fmt = new DecimalFormat("0.0000"); fmt.setRoundingMode(RoundingMode.DOWN); double sqrt = Math.sqrt(Long.parseLong(s)); return fmt.format(sqrt); } } |
|
|