Dianov

Conditional Statements - Exercise (07. World Swimming Record)

Oct 18th, 2020 (edited)
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.99 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 WorldSwimmingRecord
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal worldRecord = decimal.Parse(Console.ReadLine());
  14.             decimal metersDistance = decimal.Parse(Console.ReadLine());
  15.             decimal timeForOneMeter = decimal.Parse(Console.ReadLine());
  16.  
  17.             decimal slowing = Math.Floor(metersDistance / 15m) * 12.50m;
  18.             decimal ivansTime = (metersDistance * timeForOneMeter) + slowing;
  19.  
  20.             if (ivansTime < worldRecord)
  21.             {
  22.                 Console.WriteLine($"Yes, he succeeded! The new world record is {ivansTime:F2} seconds.");
  23.             }
  24.             else
  25.             {
  26.                 decimal slowertime = ivansTime - worldRecord;
  27.                 Console.WriteLine($"No, he failed! He was {slowertime:F2} seconds slower.");
  28.             }
  29.         }
  30.     }
  31. }
Add Comment
Please, Sign In to add comment