IvetValcheva

01. Sum Seconds

Nov 7th, 2021
200
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.69 KB | None | 0 0
  1. using System;
  2.  
  3. namespace demo
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int time1 = int.Parse(Console.ReadLine()); //50
  10.             int time2 = int.Parse(Console.ReadLine()); //60
  11.             int time3 = int.Parse(Console.ReadLine()); //13
  12.            
  13.  
  14.             int totalTime = time1 + time2 + time3; //123
  15.  
  16.             int min = totalTime / 60; //123/60=2 (3)
  17.             int sec = totalTime % 60; //123%60=3
  18.  
  19.             if (sec < 10)
  20.             {
  21.                 Console.WriteLine($"{min}:0{sec}");
  22.             }
  23.             else
  24.             {
  25.                 Console.WriteLine($"{min}:{sec}");
  26.             }
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment