Advertisement
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 athlete1 = Integer.parseInt(scanner.nextLine());
- int athlete2 = Integer.parseInt(scanner.nextLine());
- int athlete3 = Integer.parseInt(scanner.nextLine());
- int sum = athlete1 + athlete2 + athlete3;
- int minutes = 0;
- int seconds = 0;
- if (sum<=59) {
- seconds=sum;
- }
- else if (sum>=60 && sum<=119 ) {
- minutes=sum/60;
- seconds=sum%60;
- }
- else if (sum>=120 && sum<=179) {
- minutes=sum/60;
- seconds=sum%60;
- }
- if (seconds<10) {
- System.out.printf("%s:0%s", minutes, seconds);
- }
- else {
- System.out.printf("%s:%s", minutes, seconds);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement