fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.io.File;
  7. import java.io.FileNotFoundException;
  8. import java.util.Scanner;
  9.  
  10. /* Name of the class has to be "Main" only if the class is public. */
  11. class Ideone
  12. {
  13. public static void main (String[] args) throws java.lang.Exception
  14. {
  15. File file = new File(System.getProperty("user.dir") + "/src/task1/input");
  16. Scanner input = null;
  17. try {
  18. input = new Scanner(file);
  19. while (input.hasNextLine()) {
  20. String[] array = input.nextLine().split(" ");
  21. calcDegree(Integer.parseInt(array[0]), Integer.parseInt(array[1]));
  22. }
  23. } catch (FileNotFoundException e) {
  24. e.printStackTrace();
  25. }
  26. }
  27.  
  28. private static void calcDegree(int hours, int minutes) {
  29. float hoursInDegree = hours * 30 + (30 * minutes) / 60f;
  30. float minutesInDegree = minutes * 6;
  31. float degree = Math.abs(hoursInDegree - minutesInDegree);
  32. float result = degree <= 180 ? degree : 360 - degree;
  33. System.out.println("Time: " + hours + " : " + minutes + ", degree: " + result);
  34. }
  35. }
Success #stdin #stdout #stderr 0.14s 50544KB
stdin
1 20
6 10
3 15
5 0
11 59
stdout
Standard output is empty
stderr
java.io.FileNotFoundException: /home/U6obVJ/src/task1/input (No such file or directory)
	at java.base/java.io.FileInputStream.open0(Native Method)
	at java.base/java.io.FileInputStream.open(FileInputStream.java:213)
	at java.base/java.io.FileInputStream.<init>(FileInputStream.java:155)
	at java.base/java.util.Scanner.<init>(Scanner.java:639)
	at Ideone.main(Main.java:18)