Advertisement
Guest User

Untitled

a guest
Jun 18th, 2018
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.66 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TimePlus15Min {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int hours = Integer.parseInt(scanner.nextLine());
  8. int minutes = Integer.parseInt(scanner.nextLine());
  9.  
  10. int time = minutes + 15;
  11.  
  12. if (time > 59) {
  13. hours = hours + 1;
  14. time = time - 60;
  15. }
  16.  
  17. if (hours > 23) {
  18. hours = hours - 24;
  19. }
  20.  
  21. if (time < 10) {
  22. System.out.printf("%d:0%d", hours, time);
  23. }
  24. else {
  25. System.out.printf("%d:%d", hours, time);
  26. }
  27.  
  28. }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement