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

I CAN´T SEE WHAT IS WRONG (JAVA )
Posted by Felix Leonel Chaves 23 Oct 2017 22:15
import java.io.InputStreamReader;
import java.text.DecimalFormat;
import java.util.Scanner;

public class Reverse {

    private static void printer(double value){
        String pattern = "###0.0000";
        DecimalFormat myFormatter = new DecimalFormat(pattern);
        String output = myFormatter.format(value);
        System.out.println(output);
    }
    public static void main(String[] args) {
        Scanner sc = new Scanner(new InputStreamReader(System.in));
        long a,b,c,d;

        a = sc.nextLong();
        b = sc.nextLong();
        c = sc.nextLong();
        d = sc.nextLong();

        printer(Math.sqrt(d));
        printer(Math.sqrt(c));
        printer(Math.sqrt(b));
        printer(Math.sqrt(a));
    }
}
Re: I CAN´T SEE WHAT IS WRONG (JAVA )
Posted by alexandrebmm 29 Mar 2018 01:27
In your solution, it is possible just 4 numbers (a,b,c,d).

Suggestion: try using a loop instead of a,b,c,d and finish the loop when the user type something different than a number