Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class primeri {
- public static void main(String[] args) {
- Scanner scanner = new Scanner (System.in);
- int hourOfExam = Integer.parseInt(scanner.nextLine());
- int minuteOfExam = Integer.parseInt(scanner.nextLine());
- int hourOfArrival = Integer.parseInt(scanner.nextLine());
- int minuteOfArrival = Integer.parseInt(scanner.nextLine());
- if (hourOfExam == hourOfArrival && minuteOfExam == minuteOfArrival){
- System.out.println("On time");
- }else if (hourOfArrival < hourOfExam || (minuteOfArrival <= minuteOfExam && hourOfArrival <= hourOfExam)){
- int allMinutesOfExam = (hourOfExam * 60) + minuteOfExam;
- int allMinuteesOfArrival = (hourOfArrival * 60) + minuteOfArrival;
- int timeBefore30min = allMinutesOfExam - 30;
- int time = allMinutesOfExam - allMinuteesOfArrival;
- if (allMinuteesOfArrival < allMinutesOfExam && allMinuteesOfArrival >= timeBefore30min) {
- System.out.println("On Time");
- if (time < 60) {
- System.out.printf("%d minutes before the start", time);
- } else{
- int b = time / 60;
- int c = time % 60;
- if (c < 10) {
- System.out.printf("%d:0%d hours before the start",b,c);
- } else
- System.out.printf("%d:%d hours before the start",b,c);
- }
- } else {
- System.out.println("Early");
- if (time < 60) {
- System.out.printf("%d minutes before the start", time);
- } else{
- int b = time / 60;
- int c = time % 60;
- if (c < 10) {
- System.out.printf("%d:0%d hours before the start",b,c);
- } else
- System.out.printf("%d:%d hours before the start",b,c);
- }
- }
- } else {
- System.out.println("Late");
- int allMinutesOfExam = (hourOfExam * 60) + minuteOfExam;
- int allMinutesOfArrival = (hourOfArrival * 60) + minuteOfArrival;
- if (allMinutesOfArrival - allMinutesOfExam < 60)
- System.out.printf("%d minutes after the start", allMinutesOfArrival - allMinutesOfExam);
- else {
- int a = allMinutesOfArrival - allMinutesOfExam;
- int b = a/60;
- int c = a%60;
- if(c<10){
- System.out.printf("%d:0%d hours after the start",b,c);
- }else
- System.out.printf("%d:%d hours after the start",b,c);
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement