if(ExcessTimeHours >= 24) {
ExcessTimeHours = 0;
}
if(ExcessTimeMin >= 60) {
ExcessTimeMin = 0;
ExcessTimeHours ++;
}
I add time when the first movie starts, then I add how long is that movie and then I add when the second movie starts, also add how long this movie is and the program will tell me if I am able to see both movies with no problem, or if I will miss some minutes of the movie or if I am not able to make it.
My problem is that I don't know how to fix that when the time reaches over midnight and jumps from 24 to 0 hours. Can't figure out the condition.
System.out.println("Start of movie A:");
System.out.print("hour: "); // 17; 23; 0
int startHourA = s.nextInt();
System.out.print("min: "); // 30; 30; 30
int startMinA = s.nextInt();
System.out.println("Length of movie A:");
System.out.print("hour: "); // 2; 2; 2
int lengthHourA = s.nextInt();
System.out.print("min: "); // 0; 0; 1
int lengthMinA = s.nextInt();
System.out.println("Start of movie B:");
System.out.print("hour: "); // 20; 0; 0
int startHourB = s.nextInt();
System.out.print("min: "); // 0; 20; 31
int startMinB = s.nextInt();
System.out.println("Length of movie B:");
System.out.print("hour: "); // 0; 1; 2
int lengthHourB = s.nextInt();
System.out.print("min: "); // 35; 35; 0
int lengthMinB = s.nextInt();
int timeBetweenMoviesHour = startHourB - ExcessTimeHours;
int timeBetweenMoviesMin = startMinB - ExcessTimeMin;
if (timeBetweenMoviesHour == 0 && timeBetweenMoviesMin >= 0) {
System.out.println("Recommendation: No problem");
}
else if (timeBetweenMoviesMin > 0) {
System.out.println("Recommendation: You won't see " +
timeBetweenMoviesMin + " minutes");
}
else System.out.println("Recommendation: You can't make it");