Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class SumSeconds {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int sec1 = Integer.parseInt(scanner.nextLine());
- int sec2 = Integer.parseInt(scanner.nextLine());
- int sec3 = Integer.parseInt(scanner.nextLine());
- int seconds = sec1 + sec2 + sec3;
- int mins = 0;
- if (seconds > 119){
- seconds -= 120;
- mins = 2;
- }else if (seconds > 59){
- seconds -= 60;
- mins = 1;
- }
- String secondsString = "";
- if(seconds < 10){
- secondsString = "0";
- }
- secondsString += Integer.toString(seconds);
- System.out.printf(mins + ":" + secondsString);
- }
- }
Add Comment
Please, Sign In to add comment