Advertisement
veronikaaa86

05. Time + 15 Minutes

Jun 13th, 2021
338
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.67 KB | None | 0 0
  1. package conditionalStatements;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P05TimePlus15Minutes {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int hour = Integer.parseInt(scanner.nextLine());
  10. int minutes = Integer.parseInt(scanner.nextLine());
  11.  
  12. int totalMinutes = (hour * 60) + minutes + 15;
  13.  
  14. int newHour = totalMinutes / 60;
  15. int newMinutes = totalMinutes % 60;
  16.  
  17. if (newHour < 24) {
  18. System.out.printf("%d:%02d", newHour, newMinutes);
  19. } else {
  20. newHour = 0;
  21. System.out.printf("%d:%02d", newHour, newMinutes);
  22. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement