fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class DistanceToOrigin
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. int x;
  13. int y;
  14. double distance;
  15.  
  16.  
  17. x=(int)(Math.random()*10);
  18. y=(int)(Math.random()*10);
  19. distance=((x^2)+(y^2));
  20. Math.sqrt(distance);
  21.  
  22. System.out.println("The distance between the coordinate (" + x + "," + y + ") and the origin is " + distance + ".");
  23. }
  24. }
Success #stdin #stdout 0.1s 320576KB
stdin
Standard input is empty
stdout
The distance between the coordinate (3,8) and the origin is 11.0.