Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class OnTimeForExam {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- Integer hourExam = Integer.parseInt(scanner.nextLine());
- Integer minExam = Integer.parseInt(scanner.nextLine());
- Integer hourArrive = Integer.parseInt(scanner.nextLine());
- Integer minArrive = Integer.parseInt(scanner.nextLine());
- Integer totalMinExamTime = hourExam*60+minExam;
- Integer totalMinArriveTime = hourArrive*60+minArrive;
- Integer diffMinTime = Math.abs(totalMinExamTime-totalMinArriveTime);
- if(totalMinExamTime.equals(totalMinArriveTime)){
- System.out.println("On time");
- }else if(totalMinExamTime > totalMinArriveTime){
- if(diffMinTime<=30){
- System.out.println("On time");
- System.out.printf("%d minutes before the start",diffMinTime);
- }else {
- if(diffMinTime<60){
- System.out.println("Early");
- System.out.printf("%d minutes before the start",diffMinTime);
- }else{
- Integer timeForHour = (int)Math.floor(diffMinTime/60);
- Integer timeForMinutes = (diffMinTime%60);
- if(timeForMinutes < 10){
- System.out.println("Early");
- System.out.printf("%d:0%d hours before the start",timeForHour, timeForMinutes);
- }else{
- System.out.println("Early");
- System.out.printf("%d:%d hours before the start", timeForHour, timeForMinutes);
- }
- }
- }
- }else{
- if(diffMinTime<=30){
- System.out.println("Late");
- System.out.printf("%d minutes after the start",diffMinTime);
- }else {
- if(diffMinTime<60){
- System.out.println("Late");
- System.out.printf("%d minutes after the start",diffMinTime);
- }else{
- Integer timeForHour = (int)Math.floor(diffMinTime/60);
- Integer timeForMinutes = (diffMinTime%60);
- if(timeForMinutes < 10){
- System.out.println("Late");
- System.out.printf("%d:0%d hours after the start",timeForHour, timeForMinutes);
- }else{
- System.out.println("Late");
- System.out.printf("%d:%d hours after the start", timeForHour, timeForMinutes);
- }
- }
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement