Can someone help me come up with a formula for calculating the difference in time? So my assignment is to write a program that prompts the user for two different times on the same day (with 0 being midnight, 0700 being 7:00 am and 2200 being 10 pm) and then returns the difference between the two times with the amount of hours and amount of minutes elapsed. For example, if the user inputted 1255 and 1305, the program should return 0 hours and 10 minutes. I'm fine with how to find the number of hours but I cannot come up with a formula for finding the difference in minutes. Here is what I have so far:

    Scanner keyboard1 = new Scanner(System.in);                 
    System.out.print("Train A departs at: ");
    int a = keyboard1.nextInt();

    Scanner keyboard2 = new Scanner(System.in);                 
    System.out.print("Train B departs at: ");
    int b = keyboard2.nextInt();

    int difference = Math.abs(a - b);
    int hours = difference / 100;
    int minutes = (I need help here);

    System.out.print("\nDifference: " + hours + " hours and " + minutes + " minutes");
The solution I originally provided here is wrong, the comments on why the question itself is out of scope are interesting though. 


      int hours = Math.abs(a - b)/ 100;

    int minutes1 = Math.min(a,b) % 100; 
    int minutes2 = Math.max(a,b) % 100; 

    int mdifference = ((Math.min(a,b) / 100) == (Math.max(a,b) / 100)) ? minutes2 - minutes1 : (60 - minutes1) + minutes2;


    System.out.print("\nDifference: " + hours + " hours and " + mdifference + " minutes");