Advertisement
PamKacz94

Untitled

Apr 5th, 2020
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.05 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class Minutes {
  4.     public static void main(String[] args){
  5.         Scanner scanner = new Scanner(System.in);
  6.  
  7.         int firstCompetition = scanner.nextInt();
  8.         int secondCompetition = scanner.nextInt();
  9.         int thirdCompetition = scanner.nextInt();
  10.  
  11.         int secondInputs = firstCompetition + secondCompetition + thirdCompetition;
  12.  
  13.         double minutes = Math.round((secondInputs / 60d) * 100d) / 100d;
  14.         double decimals = Math.round((minutes - Math.floor(minutes)) * 100d) / 100d ;
  15.         int seconds =  (int)Math.round(decimals * 60);
  16.  
  17.         if (seconds < 10){
  18.             System.out.println((int) minutes + ":0" + seconds);
  19.         } else if (seconds == 0){
  20.             System.out.println((int) minutes + ":00");
  21.         } else if (seconds == 10 & seconds == 20 & seconds == 30 & seconds == 40 & seconds == 50){
  22.             System.out.println((int) minutes + ":" + seconds + "0");
  23.         } else {
  24.             System.out.println((int) minutes + ":" + seconds);
  25.         }
  26.  
  27.  
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement