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 myScan = new Scanner(System.in);
- int hourExam = Integer.parseInt(myScan.nextLine());
- int minutesExam = Integer.parseInt(myScan.nextLine());
- int hourArrival = Integer.parseInt(myScan.nextLine());
- int minutesArrival = Integer.parseInt(myScan.nextLine());
- int timeExam=hourExam*60+minutesExam;
- int timeArrival=hourArrival*60+minutesArrival;
- int diff=timeExam-timeArrival;
- String text="before";
- if (diff<0){
- System.out.println("Late");
- text="after";
- }else if (diff<=30){
- System.out.println("On time");
- }else{
- System.out.println("Early");
- }
- diff=Math.abs(diff);
- if (diff>0&&diff<60){
- System.out.printf("%d minutes %s the start",diff,text);
- }else if (diff>=60){
- System.out.printf("%d:%02d hours %s the start",diff/60,diff%60,text);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement