Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Sportisti {
- public static void main(String[] args) {
- Scanner scan = new Scanner(System.in);
- System.out.print("Vreme na sustezatel 1: ");
- int sustezatel1 = Integer.parseInt(scan.nextLine());
- proverka(sustezatel1);
- System.out.print("Vreme na sustezatel 2: ");
- int sustezatel2 = Integer.parseInt(scan.nextLine());
- proverka(sustezatel2);
- System.out.print("Vreme na sustezatel 3: ");
- int sustezatel3 = Integer.parseInt(scan.nextLine());
- proverka(sustezatel3);
- scan.close();
- System.out.println();
- int sum = sustezatel1 + sustezatel2 + sustezatel3;
- int minutes = Math.abs(sum / 60);
- int seconds = Math.abs(sum % 60);
- System.out.printf("Total time: %d:%02d", minutes, seconds);
- }
- public static void proverka(int vreme) {
- if (!(vreme > 0 && vreme <= 50)) {
- System.out.println();
- System.out.print("Invalid time");
- System.exit(0);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement