Advertisement
Sasho_Cvetkov17101

Untitled

Apr 6th, 2020
32
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class sustezatel {
  4. public static void main(String[] args) {
  5.  
  6. Scanner scanner = new Scanner(System.in);
  7.  
  8. System.out.print("Vreme na igrach 1: ");
  9. int sustezatel1 = Integer.parseInt(scanner.nextLine());
  10. if (!(sustezatel1 > 0 && sustezatel1 <= 50)) {
  11. System.out.println();
  12. System.out.print("Invalid time");
  13. return;
  14. }
  15.  
  16. System.out.print("Vreme na igrach 2: ");
  17. int sustezatel2 = Integer.parseInt(scanner.nextLine());
  18. if (!(sustezatel2 > 0 && sustezatel2 <= 50)) {
  19. System.out.println();
  20. System.out.print("Invalid time");
  21. return;
  22. }
  23.  
  24. System.out.print("Vreme na igrach 3: ");
  25. int sustezatel3 = Integer.parseInt(scanner.nextLine());
  26. if (!(sustezatel3 > 0 && sustezatel3 <= 50)) {
  27. System.out.println();
  28. System.out.print("Invalid time");
  29. return;
  30. }
  31. System.out.println();
  32.  
  33. int sum = sustezatel1 + sustezatel2+ sustezatel3;
  34. int minutes = Math.abs(sum / 60);
  35. int seconds = Math.abs(sum % 60);
  36.  
  37. System.out.printf("Total time: %d:%02d", minutes, seconds);
  38. }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement