Advertisement
Guest User

zadacha

a guest
Apr 2nd, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. class zadacha {
  4. public static void main(String[] args) {
  5. Scanner scan = new Scanner(System.in);
  6.  
  7. int time1 = scan.nextInt();
  8. int time2 = scan.nextInt();
  9. int time3 = scan.nextInt();
  10. int collectedTime = time1+time2+time3;
  11. int minutes = 0;
  12.  
  13. if(time1 < 0 || time1 > 50 ||time2 < 0 || time2 > 50 ||time3 < 0 || time3 > 50){
  14. System.out.println("Error, invalid time!");
  15. return;
  16. }
  17.  
  18. if(time1 < 10){
  19. System.out.println("0"+time1);
  20. }else{
  21. System.out.println(time1);
  22. }
  23. if(time2 < 10){
  24. System.out.println("0"+time2);
  25. }else{
  26. System.out.println(time2);
  27. }
  28. if(time3 < 10){
  29. System.out.println("0"+time3);
  30. }else{
  31. System.out.println(time3);
  32. }
  33.  
  34. while(collectedTime > 60){
  35. collectedTime-=60;
  36. minutes++;
  37. }
  38. if(collectedTime < 10){
  39. System.out.println(minutes+":0"+collectedTime);
  40. }else{
  41. System.out.println(minutes+":"+collectedTime);
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement