Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - Lab (04. Back In 30 Minutes)

Mar 11th, 2021
309
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.20 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 BackIn30Minutes
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int hours = int.Parse(Console.ReadLine());
  14.             int minutes = int.Parse(Console.ReadLine());
  15.  
  16.             int hoursAfter30 = hours * 60 + minutes + 30;
  17.             if (hoursAfter30 % 60 < 10)
  18.             {
  19.                 if (hoursAfter30 / 60 >= 24)
  20.                 {
  21.                     Console.WriteLine($"{hoursAfter30 / 60 - 24}:0{hoursAfter30 % 60}");
  22.                 }
  23.                 else
  24.                 {
  25.                     Console.WriteLine($"{hoursAfter30 / 60}:0{hoursAfter30 % 60}");
  26.                 }                
  27.             }
  28.             else
  29.             {
  30.                 if (hoursAfter30 / 60 >= 24)
  31.                 {
  32.                     Console.WriteLine($"{hoursAfter30 / 60 - 24}:{hoursAfter30 % 60}");
  33.                 }
  34.                 else
  35.                 {
  36.                     Console.WriteLine($"{hoursAfter30 / 60}:{hoursAfter30 % 60}");                  
  37.                 }                
  38.             }
  39.         }
  40.     }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement