fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. double x1 = 0.0;
  10. double y1 = 0.0;
  11. double y2 = 0.0;
  12. double radius = 1.5;
  13. double increment = 0.1;
  14.  
  15. //table heading
  16. System.out.println(" Points on a Circle of Radius " + radius);
  17. System.out.printf("%6s%8s%8s%8s%n", "x1", "y1", "x1", "y2");
  18. System.out.println(" -------------------------------------");
  19.  
  20. //for loop processes coordinates and outputs to table
  21. for (x1 = radius; x1 >= (radius * -1); x1 -= increment){
  22. y1 = Math.sqrt(Math.pow(radius, 2) - Math.pow(x1, 2));
  23. y2 = 0 - Math.abs(y1);
  24. System.out.printf("%7.2f%8.2f%8.2f%8.2f%n", x1, y1, x1, y2);
  25. }
  26. }
  27. }
Success #stdin #stdout 0.15s 37020KB
stdin
Standard input is empty
stdout
    Points on a Circle of Radius 1.5
    x1      y1      x1      y2
 -------------------------------------
   1.50    0.00    1.50    0.00
   1.40    0.54    1.40   -0.54
   1.30    0.75    1.30   -0.75
   1.20    0.90    1.20   -0.90
   1.10    1.02    1.10   -1.02
   1.00    1.12    1.00   -1.12
   0.90    1.20    0.90   -1.20
   0.80    1.27    0.80   -1.27
   0.70    1.33    0.70   -1.33
   0.60    1.37    0.60   -1.37
   0.50    1.41    0.50   -1.41
   0.40    1.45    0.40   -1.45
   0.30    1.47    0.30   -1.47
   0.20    1.49    0.20   -1.49
   0.10    1.50    0.10   -1.50
  -0.00    1.50   -0.00   -1.50
  -0.10    1.50   -0.10   -1.50
  -0.20    1.49   -0.20   -1.49
  -0.30    1.47   -0.30   -1.47
  -0.40    1.45   -0.40   -1.45
  -0.50    1.41   -0.50   -1.41
  -0.60    1.37   -0.60   -1.37
  -0.70    1.33   -0.70   -1.33
  -0.80    1.27   -0.80   -1.27
  -0.90    1.20   -0.90   -1.20
  -1.00    1.12   -1.00   -1.12
  -1.10    1.02   -1.10   -1.02
  -1.20    0.90   -1.20   -0.90
  -1.30    0.75   -1.30   -0.75
  -1.40    0.54   -1.40   -0.54