Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package CodnitionalStatements;
- import java.util.Scanner;
- public class SumSeconds_01 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int firstTime = Integer.parseInt(scanner.nextLine());
- int secondTime = Integer.parseInt(scanner.nextLine());
- int thirdTime = Integer.parseInt(scanner.nextLine());
- //намираме сумата от времената на тримата -> секунди
- int sumInSeconds = firstTime + secondTime + thirdTime;
- //преобразувам сумата от секунди -> минути и секунди
- int minutes = sumInSeconds / 60;
- int seconds = sumInSeconds % 60;
- //печатаме
- //секунди < 10 -> минути:0секунди
- //секунди >= 10 -> минути:секунди
- if (seconds < 10) {
- System.out.printf("%d:0%d", minutes, seconds);
- } else { //seconds >= 10
- System.out.printf("%d:%d", minutes, seconds);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment