fork(1) 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 Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. double aspect_ratio = 17.0 / 7.0;
  13. int image_width = 400;
  14.  
  15. int image_height = (int)(image_width / aspect_ratio);
  16.  
  17. double viewport_height = 2.0;
  18. double viewport_width = viewport_height * image_width / image_height;
  19.  
  20. System.out.printf("Aspect ratio: %f\n", aspect_ratio);
  21. System.out.printf("Image: %d x %d\n", image_width, image_height);
  22. System.out.printf("Viewport: %f x %f\n", viewport_width, viewport_height);
  23. }
  24. }
Success #stdin #stdout 0.1s 37348KB
stdin
Standard input is empty
stdout
Aspect ratio: 2.428571
Image: 400 x 164
Viewport: 4.878049 x 2.000000