Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- /**
- * Created by User on 17.8.2017 г..
- */
- public class demo {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int examHour = Integer.parseInt(scanner.nextLine());
- int examMin = Integer.parseInt(scanner.nextLine());
- int arrivalHour = Integer.parseInt(scanner.nextLine());
- int arrivalMin = Integer.parseInt(scanner.nextLine());
- int examMinutes = examHour * 60 + examMin;
- int arrivalMinutes = arrivalHour * 60 + arrivalMin;
- int timeDiff = examMinutes - arrivalMinutes;
- if(timeDiff < 0){
- int hour = Math.abs(timeDiff) / 60;
- int mins = Math.abs(timeDiff) % 60;
- if (hour > 0){
- System.out.printf
- ("Late\n%d:%02d hours after the start", hour, mins);
- }else{
- System.out.printf
- ("Late\n%d minutes after the start",mins);
- }
- }if(timeDiff >= 0 && timeDiff <= 30 ){
- int mins = Math.abs(timeDiff) % 60;
- if(mins == 0) {
- System.out.println("On time");
- }else {
- System.out.printf("On time\n%d minutes before the start", mins);
- }
- }if(timeDiff > 30){
- int hour = Math.abs(timeDiff) / 60;
- int mins = Math.abs(timeDiff) % 60;
- if (hour > 0){
- System.out.printf
- ("Early\n%d:%02d hours before the start", hour, mins);
- }else{
- System.out.printf
- ("Early\n%d minutes before the start", mins);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement