Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package L02_ConditionalStatements;
- import java.util.Scanner;
- public class P03_TimePlus15Minutes {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- // Прочитаме входните данни
- // Превръщаме всичко в минути
- // Пресмятаме часовете и минутите, след като добавим 15 минути
- // Проверим колко са часовете -> ако са 24 трябва да ги направим 0
- int hours = Integer.parseInt(scanner.nextLine());
- int minutes = Integer.parseInt(scanner.nextLine());
- int totalMinutes = hours * 60 + minutes + 15;
- int finalHours = totalMinutes / 60;
- int finalMinutes = totalMinutes % 60;
- if (finalHours >= 24){
- finalHours = 0;
- System.out.printf("%d:%02d", finalHours, finalMinutes);
- } else {
- System.out.printf("%d:%02d", finalHours, finalMinutes);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment