Advertisement
veronikaaa86

sum sec if-else

Nov 18th, 2017
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.63 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class SumSeconds1 {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6.  
  7. int athlete1 = Integer.parseInt(scanner.nextLine());
  8. int athlete2 = Integer.parseInt(scanner.nextLine());
  9. int athlete3 = Integer.parseInt(scanner.nextLine());
  10.  
  11. int sum = athlete1 + athlete2 + athlete3;
  12. int minutes = sum/60;
  13. int seconds = sum%60;
  14.  
  15. if (seconds<10) {
  16. System.out.printf("%d:0%d", minutes, seconds);
  17. } else {
  18. System.out.printf("%d:%d", minutes, seconds);
  19. }
  20. }
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement