Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package BasicsOverview;
- import java.util.Scanner;
- public class TimeAfter30Minutes_04 {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- //1. входни данни
- int currentHours = Integer.parseInt(scanner.nextLine());
- int currentMinutes = Integer.parseInt(scanner.nextLine());
- //2. изчислявам текущото време в минути
- int currentTimeInMinutes = currentHours * 60 + currentMinutes;
- //3. доабвям 30 минути към текущото време
- int timeAfter30Minutes = currentTimeInMinutes + 30;
- //4. преобразуваме: часове и минути
- int endHour = timeAfter30Minutes / 60;
- int endMinutes = timeAfter30Minutes % 60;
- //!!!!
- if (endHour == 24) {
- endHour = 0;
- }
- //5. отпечатваме -> hh:mm
- System.out.printf("%d:%02d", endHour, endMinutes);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment