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. Scanner sc = new Scanner(System.in);
  13.  
  14. int firstX;
  15. int firstY;
  16. int secondX;
  17. int secondY;
  18. boolean canContinue = false;
  19. int firstCl = sc.nextInt();
  20. int secondCl = sc.nextInt();
  21. String str = sc.next;
  22. String str1 = sc.next;
  23. sc.close();
  24. if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
  25. System.out.println(-1);
  26. }
  27. else{
  28. if((firstCl%2 == 0 && (str.charAt(0) == 'b' || str.charAt(0) == 'd' || str.charAt(0) == 'f' || str.charAt(0) == 'h')) && (secondCl%2 == 0 && (str1.charAt(0) == 'a' || str1.charAt(0) == 'c' || str1.charAt(0) == 'e' || str1.charAt(0) == 'h'))){
  29. canContinue = true;
  30. }
  31.  
  32. if(!canContinue){
  33. System.out.println(-1);
  34. }
  35. else{
  36. firstX = firstCl;
  37. firstY = getCoordinate(str.charAt(0));
  38. secondX = secondCl;
  39. secondY = getCoorinate(str1.charAt(0));
  40. if(firstY - secondY < 0){
  41. int totalY = secondY - firstY;
  42. int totalX = secondX - firstX;
  43. if(totalX < 0){
  44. totalX = totalX * -1;
  45. }
  46. System.out.println(totalX + totalY - 1);
  47. }
  48. }
  49. }
  50. }
  51.  
  52. public int getCoordinate(Char ch){
  53. if(ch == 'a' || ch == 'b'){
  54. return 0;
  55. }
  56. else if(ch == 'c' || ch == 'd'){
  57. return 1;
  58. }
  59. else if(ch == 'e' || ch == 'f'){
  60. return 2;
  61. }
  62. else if(ch == 'g' || ch == 'h'){
  63. return 3;
  64. }
  65. }
  66. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:52: error: cannot find symbol
	public int getCoordinate(Char ch){
	                         ^
  symbol:   class Char
  location: class Ideone
Main.java:21: error: cannot find symbol
		String str = sc.next;
		               ^
  symbol:   variable next
  location: variable sc of type Scanner
Main.java:22: error: cannot find symbol
		String str1 = sc.next;
		                ^
  symbol:   variable next
  location: variable sc of type Scanner
Main.java:24: error: cannot find symbol
		if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
		     ^
  symbol:   variable firstB
  location: class Ideone
Main.java:24: error: cannot find symbol
		if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
		                     ^
  symbol:   variable firstB
  location: class Ideone
Main.java:24: error: cannot find symbol
		if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
		                                         ^
  symbol:   variable secondB
  location: class Ideone
Main.java:24: error: cannot find symbol
		if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
		                                                          ^
  symbol:   variable secondB
  location: class Ideone
Main.java:24: error: cannot find symbol
		if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
		                                                                             ^
  symbol:   variable firstN
  location: class Ideone
Main.java:24: error: cannot find symbol
		if(!(firstB < 'g' && firstB >= 'a') || !(secondB < 'g' && secondB >= 'a') || firstN == secondN){
		                                                                                       ^
  symbol:   variable secondN
  location: class Ideone
Main.java:37: error: non-static method getCoordinate(Char) cannot be referenced from a static context
				firstY = getCoordinate(str.charAt(0));
				         ^
Main.java:39: error: cannot find symbol
				secondY = getCoorinate(str1.charAt(0));
				          ^
  symbol:   method getCoorinate(char)
  location: class Ideone
11 errors
stdout
Standard output is empty