Advertisement
borkins

07b. Sum Seconds

Mar 23rd, 2017
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.45 KB | None | 0 0
  1. /*
  2.  * Simple Conditions
  3.  */
  4. import java.util.Scanner;
  5.  
  6. public class _07b_SumSeconds
  7. {
  8.     public static void main(String[] args)
  9.     {
  10.         Scanner scan = new Scanner(System.in);
  11.         int totalSeconds = 0;
  12.        
  13.         // Using 'for' loop to input and sum all seconds
  14.         for (int i = 0; i < 3; i++) {
  15.             totalSeconds += Integer.parseInt(scan.nextLine());
  16.         }
  17.         System.out.printf("%d:%02d", (totalSeconds / 60), (totalSeconds % 60));
  18.     }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement