Gibt es eine Möglichkeit, in Java ein 24-Stunden-Format und ein 60-minütiges Format zu erstellen?Java

Java-Forum
Guest
 Gibt es eine Möglichkeit, in Java ein 24-Stunden-Format und ein 60-minütiges Format zu erstellen?

Post by Guest »

Code: Select all

if(ExcessTimeHours >= 24) {
ExcessTimeHours = 0;
}
if(ExcessTimeMin >= 60) {
ExcessTimeMin = 0;
ExcessTimeHours ++;
}
< /code>
Ich füge Zeit hinzu, wenn der erste Film startet, dann füge ich hinzu, wie lange dieser Film dauert und dann füge ich hinzu, wenn der zweite Film beginnt, auch wie lange dieser Film ist und das Programm wird es erzählen Ich, wenn ich in der Lage bin, beide Filme ohne Problem zu sehen oder wenn ich einige Minuten des Films verpassen werde oder wenn ich es nicht schaffen kann. Ich weiß nicht, wie man das behebt, wenn die Zeit über Mitternacht reicht und von 24 bis 0 Stunden springt. Die Bedingung kann nicht herausfinden. < /P>
    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");

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post