Advertisement
MartinYanchev-99

Swimming record

Aug 29th, 2017
369
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.             double theRecord = double.Parse(Console.ReadLine());
  14.             double distance = double.Parse(Console.ReadLine());
  15.             double timeForOneMeter = double.Parse(Console.ReadLine());
  16.             double timeNeedToSwimm = distance * timeForOneMeter;
  17.             double lateing = (distance / 15) * 12.5;
  18.             double totalTime = timeNeedToSwimm + lateing;
  19.             double diff = Math.Abs(theRecord - totalTime);
  20.             if (totalTime<theRecord)
  21.             {
  22.                 Console.WriteLine($"Yes, he succeeded! The new world record is {totalTime:f2} seconds.");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine($"No, he failed! He was {diff:f2} seconds slower.");
  27.             }
  28.  
  29.  
  30.         }
  31.     }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement