Advertisement
CoineTre

Add 15min to Time

Oct 13th, 2020
51
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TimeAdd15Min {
  4.     public static void main(String[] args) {
  5.         Scanner scanner = new Scanner(System.in);
  6.         int hours = Integer.parseInt(scanner.nextLine());
  7.         int minutes = Integer.parseInt(scanner.nextLine());
  8.         int timeInMinutes = hours * 60 + minutes;
  9.         int addTime = timeInMinutes + 15;
  10.         int totalTimeHours = addTime / 60;
  11.         int totalTimeMinutes = addTime % 60;
  12.         if(totalTimeHours == 24){
  13.         totalTimeHours =0;
  14.     }
  15.         System.out.printf("%d:%02d", totalTimeHours,totalTimeMinutes);
  16.  
  17.     }
  18. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement