Advertisement
Guest User

Untitled

a guest
May 22nd, 2019
120
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. package com.company;
  2.  
  3. import java.io.BufferedReader;
  4. import java.io.IOException;
  5. import java.io.InputStreamReader;
  6. import java.lang.reflect.Array;
  7. import java.util.*;
  8. import java.util.regex.Matcher;
  9. import java.util.regex.Pattern;
  10. import java.util.stream.Collectors;
  11.  
  12. public class Main {
  13.  
  14.  
  15.  
  16.  
  17.  
  18. public static void main(String[] args) throws IOException {
  19.  
  20.  
  21. BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  22.  
  23. Scanner scanner = new Scanner(System.in);
  24.  
  25. int hours = Integer.parseInt(scanner.nextLine());
  26. int minutes = Integer.parseInt(scanner.nextLine());
  27.  
  28. int allminutes = hours*60 + minutes + 30;
  29.  
  30. int newHours = allminutes/60;
  31. int newMinutes = allminutes%60;
  32.  
  33. if (newHours > 23){
  34.  
  35. newHours%=24;
  36. if (newMinutes <10){
  37. System.out.printf("%d:0%d",newHours, newMinutes);
  38. }else {
  39. System.out.printf("%d:%d",newHours, newMinutes);
  40. }
  41. }else if (newHours<10){
  42.  
  43. /// Принтираш повече от веднъж при вход 0 и 30 принтира два пъри два различни входа защото правеше проверката за минутите дали са по-малко от 10 чак след като беше принтирал веднъж резултат ///
  44. if ( newMinutes < 10 ){
  45. System.out.printf("%d:0%d", newHours, newMinutes);
  46. }else {
  47. System.out.printf("%d:%d", newHours, newMinutes);
  48. }
  49. }else {
  50. if (newMinutes < 10) {
  51. System.out.printf("%d:0%d", newHours, newMinutes);
  52. }else {
  53. System.out.printf("%d:%d", newHours, newMinutes);
  54. }
  55. }
  56. }
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement