kirililchev3

Sum Seconds - if

May 18th, 2018
255
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.07 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int firstCompetitor = int.Parse(Console.ReadLine());
  10.             int secondCompetitor = int.Parse(Console.ReadLine());
  11.             int thirdCompetitor = int.Parse(Console.ReadLine());
  12.  
  13.             int seconds = firstCompetitor + secondCompetitor + thirdCompetitor;
  14.             int minutes = 0;
  15.  
  16.             if (seconds <= 59)
  17.             {
  18.                 minutes = 0;
  19.                 seconds = seconds;
  20.             } else if (seconds > 59 && seconds <= 119)
  21.             {
  22.                 minutes++;
  23.                 seconds = seconds - 60;
  24.             } else if (seconds > 119 && seconds <= 179)
  25.             {
  26.                 minutes += 2;
  27.                 seconds = seconds - 120;
  28.             }
  29.             if (seconds < 10)
  30.             {
  31.                 Console.WriteLine(minutes + ":" + "0" + seconds);
  32.             } else
  33.             {
  34.                 Console.WriteLine(minutes + ":" + seconds);
  35.             }
  36.         }
  37.     }
  38. }
Advertisement
Add Comment
Please, Sign In to add comment