Advertisement
veronikaaa86

03. Time + 15 Minutes

Nov 7th, 2021
258
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. package conditionalStatemnents;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class P03TimePlus15Minutes {
  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 allMinutes = (hour * 60) + minutes + 15;
  13.  
  14. int newHour = allMinutes / 60;
  15. int newMin = allMinutes % 60;
  16.  
  17. if (newHour > 23) {
  18. newHour = 0;
  19. System.out.printf("%d:%02d", newHour, newMin);
  20. } else {
  21. System.out.printf("%d:%02d", newHour, newMin);
  22. }
  23. }
  24. }
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement