Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OnTimeForTheExam_09 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int examH = Integer.parseInt(scanner.nextLine());
- int examM = Integer.parseInt(scanner.nextLine());
- int comeH = Integer.parseInt(scanner.nextLine());
- int comeM = Integer.parseInt(scanner.nextLine());
- int examHToM = (examH * 60) + examM;
- int comeHToM = (comeH * 60) + comeM;
- int timeH = 0;
- int timeM = 0;
- if (examHToM > comeHToM && examHToM - 30 >= comeHToM){
- timeH = examHToM / comeHToM;
- timeM = examHToM % comeHToM;
- System.out.printf("On time %n%d minutes before the start", timeM);
- }else if (examHToM - 30 < comeHToM ){
- timeH = examHToM / comeHToM;
- timeM = examHToM % comeHToM;
- if (timeM == 60){
- timeM = 0;
- }
- System.out.printf("Early %n%d:%02d hours before the start", timeH, timeM);
- }else if (examHToM < comeHToM){
- timeH = comeHToM / examHToM;
- timeM = comeHToM % examHToM;
- if (timeH >= 1) {
- System.out.printf("Late %n%d:%0d hours after the start",timeH, timeM);
- }else if (timeH == 0 ){
- System.out.printf("Late %n%0d minutes after the start", timeM);
- }
- }else if (examHToM == comeHToM){
- System.out.printf("On time ");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement