Advertisement
dragonbs

WorldSwimmingRecord

Oct 22nd, 2022
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.12 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _06.WorldSwimmingRecord
  4. {
  5.     internal class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double worldRecordd = double.Parse(Console.ReadLine());
  10.             double distanceInMeter = double.Parse(Console.ReadLine());
  11.             double timeInSecondsForMetres = double.Parse(Console.ReadLine());
  12.  
  13.             double distanceToSwimInSecond = distanceInMeter * timeInSecondsForMetres;
  14.             double waterResistance = Math.Floor(distanceInMeter / 15);
  15.             double addedTime = waterResistance * 12.5;
  16.  
  17.             double finalTimeForSwim = distanceToSwimInSecond + addedTime;
  18.  
  19.             bool isRecordBeat = finalTimeForSwim < worldRecordd;
  20.  
  21.             if (isRecordBeat)
  22.             {
  23.                 Console.WriteLine($"Yes, he succeeded! The new world record is {finalTimeForSwim:F2} seconds.");
  24.             }
  25.             else
  26.             {
  27.                 double neededSeconds = Math.Abs(worldRecordd - finalTimeForSwim);
  28.                 Console.WriteLine($"No, he failed! He was {neededSeconds:F2} seconds slower.");
  29.             }
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement