Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Test {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int hourExam = Integer.parseInt(scanner.nextLine());
- int minutesExam = Integer.parseInt(scanner.nextLine());
- int hourArrive = Integer.parseInt(scanner.nextLine());
- int minutesArrive = Integer.parseInt(scanner.nextLine());
- int totalExamTime = hourExam * 60 + minutesExam;
- int totalArriveTime = hourArrive * 60 + minutesArrive;
- if (totalArriveTime > totalExamTime) {
- System.out.println("Late");
- int lateMinutes = totalArriveTime - totalExamTime;
- if (lateMinutes < 60) {
- System.out.printf("%d minutes after the start", lateMinutes);
- } else {
- int hour = lateMinutes / 60;
- int minutes = lateMinutes % 60;
- System.out.printf("%d:%02d hours after the start", hour, minutes);
- }
- } else if (totalArriveTime == totalExamTime || totalExamTime - totalArriveTime <= 30) { // промених < с <=
- System.out.println("On time");
- int ontime = totalExamTime - totalArriveTime;
- if (ontime <= 30 && ontime != 0) {
- System.out.printf("%d minutes before the start", ontime);
- }
- } else if (totalExamTime - totalArriveTime > 30) {
- System.out.println("Early");
- int earlyMinutes = totalExamTime - totalArriveTime;
- if (earlyMinutes < 60) {
- System.out.printf("%d minutes before the start", earlyMinutes);
- } else {//earlyMinutes>=60
- int hours = earlyMinutes / 60;
- int minutes = earlyMinutes % 60;
- System.out.printf("%d:%02d hours before the start", hours, minutes); // имаше правописна грешка
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment