ENG  RUSTimus Online Judge
Online Judge
Problems
Authors
Online contests
About Online Judge
Frequently asked questions
Site news
Webboard
Links
Problem set
Submit solution
Judge status
Guide
Register
Update your info
Authors ranklist
Current contest
Scheduled contests
Past contests
Rules
back to board

Discussion of Problem 1001. Reverse Root

What is wrong with this solution? Judge is giving output as Wrong Answer
Posted by nahusha 26 Oct 2017 19:50
import java.util.Scanner;
import java.util.Stack;

public class ReverseRoot_SplitDecimal {

    public static void main(String args[]) {

        Scanner sc = new Scanner(System.in);
        Stack<Integer> integerNumberStack = new Stack<Integer>();
        Stack<Short> floatingNumberStack = new Stack<Short>();

        Double tempDouble = new Double(0);

        while(sc.hasNextInt()) {
            tempDouble = Math.sqrt(sc.nextDouble());
            integerNumberStack.push(Integer.parseInt(String.format("%.4f", tempDouble).split("\\.")[0]));
            floatingNumberStack.push(Short.parseShort(String.format("%.4f", tempDouble).split("\\.")[1]));
        }

        while(!integerNumberStack.isEmpty()) {
            System.out.printf("\n%d.%04d", integerNumberStack.pop(), floatingNumberStack.pop());
        }
        System.out.println();

        sc.close();
    }
}