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 Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. double distance, planeSpeed, objectSpeed;
  13. double timeToCollision;
  14.  
  15. Scanner input = new Scanner(System.in);
  16. System.out.print("Enter distance of nearest object: ");
  17. distance = input.nextDouble();
  18. System.out.print("Enter speed of the plane: ");
  19. planeSpeed = input.nextDouble();
  20. System.out.print("Enter speed of the object: ");
  21. objectSpeed = input.nextDouble();
  22.  
  23. timeToCollision = distance / (planeSpeed + objectSpeed);
  24.  
  25. if (timeToCollision >= 10) {
  26. System.out.println("\nAvert object!");
  27. } else {
  28. System.out.println("\nEject passengers!");
  29. }
  30. }
  31. }
Success #stdin #stdout 0.11s 380736KB
stdin
100 5 2
stdout
Enter distance of nearest object: Enter speed of the plane: Enter speed of the object: 
Avert object!