Advertisement
Kent_St_1

RetakeExamPart1-6Janurary2017SinoTheWaker_01

Aug 23rd, 2021
843
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.75 KB | None | 0 0
  1.  
  2.  
  3. import java.text.ParseException;
  4. import java.time.LocalTime;
  5. import java.time.format.DateTimeFormatter;
  6. import java.util.Scanner;
  7.  
  8.  
  9. public class SinoTheWalker_01 {
  10.     public static void main(String[] args) throws ParseException {
  11.         Scanner scan = new Scanner(System.in);
  12.         String timeToString = scan.nextLine();
  13.         DateTimeFormatter parseFormat = DateTimeFormatter.ofPattern("HH:mm:ss");
  14.         LocalTime time = LocalTime.parse(timeToString, parseFormat);
  15.         int steps = Integer.parseInt(scan.nextLine()) % 86400;
  16.         int secondsByEachStep = Integer.parseInt(scan.nextLine()) % 86400;
  17.         int result = steps * secondsByEachStep;
  18.         LocalTime newTime = time.plusSeconds(result);
  19.         int h = newTime.getHour();
  20.         int m = newTime.getMinute();
  21.         int s = newTime.getSecond();
  22.         if (h < 9 && m > 9 && s > 9) {
  23.             System.out.printf("Time Arrival: 0%d:%d:%d", h, m, s);
  24.         } else if (h > 9 && m < 9 && s > 9) {
  25.             System.out.printf("Time Arrival: %d:0%d:%d", h, m, s);
  26.         } else if (h > 9 && m > 9 && s < 9) {
  27.             System.out.printf("Time Arrival: %d:%d:0%d", h, m, s);
  28.         } else if (h < 9 && m < 9 && s < 9) {
  29.             System.out.printf("Time Arrival: 0%d:0%d:0%d", h, m, s);
  30.         } else if (h > 9 && m > 9 && s > 9) {
  31.             System.out.printf("Time Arrival: %d:%d:%d", h, m, s);
  32.         } else if (h < 9 && m < 9 && s > 9) {
  33.             System.out.printf("Time Arrival: 0%d:0%d:%d", h, m, s);
  34.         } else if (h < 9 && m > 9 && s < 9) {
  35.             System.out.printf("Time Arrival: 0%d:%d:0%d", h, m, s);
  36.         } else if (h > 9 && m < 9 && s < 9) {
  37.             System.out.printf("Time Arrival: %d:0%d:0%d", h, m, s);
  38.         }
  39.  
  40.     }
  41. }
  42.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement