Dianov

Conditional Statements - Exercise (01. Sum Seconds)

Oct 16th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.80 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace SumSeconds
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int firstTime = int.Parse(Console.ReadLine());
  14.             int secondTime = int.Parse(Console.ReadLine());
  15.             int thirdTime = int.Parse(Console.ReadLine());
  16.  
  17.             int summedTime = firstTime + secondTime + thirdTime;
  18.             int minutes = summedTime / 60;
  19.             int seconds = summedTime % 60;
  20.  
  21.             if (seconds < 10)
  22.             {
  23.                 Console.WriteLine("{0}:0{1}", minutes, seconds);
  24.             }
  25.             else
  26.             {
  27.                 Console.WriteLine("{0}:{1}", minutes, seconds);
  28.             }
  29.         }
  30.     }
  31. }
Advertisement
Add Comment
Please, Sign In to add comment