Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OnTimeForTheExam {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int examHours = Integer.parseInt(scanner.nextLine());
- int examMins = Integer.parseInt(scanner.nextLine());
- int arrivalHours = Integer.parseInt(scanner.nextLine());
- int arrivalMins = Integer.parseInt(scanner.nextLine());
- int examTimeInMins = examHours * 60 + examMins;
- int arrivalTimeInMins = arrivalHours * 60 + arrivalMins;
- int time = examTimeInMins - arrivalTimeInMins;
- if(time < 0){
- System.out.println("Late");
- int hours = Math.abs(time) / 60;
- int mins = Math.abs(time) % 60;
- if(time > -60){
- System.out.printf("%d minutes after the start", mins);
- }else{
- System.out.printf("%d:%02d hours after the start", hours, mins);
- }
- }else if(time <= 30){
- System.out.println("On time");
- if(time > 0){
- System.out.printf("%d minutes before the start", time);
- }
- }else{
- System.out.println("Early");
- int hours = time / 60;
- int mins = time % 60;
- if(time >= 60){
- System.out.printf("%d:%02d hours before the start",hours, mins );
- }else{
- System.out.printf("%d minutes before the start", mins);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement