Advertisement
NelIfandieva

Lec02_Ex06_SwimmingRecord

Mar 8th, 2022
942
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.  
  3. namespace ConditionalStatements
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             double recordInSec = double.Parse(Console.ReadLine());
  10.             double distanceInMeters = double.Parse(Console.ReadLine());
  11.             double timeInSecPerMeter = double.Parse(Console.ReadLine());
  12.  
  13.             double timeForDistance = distanceInMeters * timeInSecPerMeter;
  14.  
  15.             double timesDelayed = Math.Floor(distanceInMeters / 15);
  16.  
  17.             double delayTime = timesDelayed * 12.5;
  18.  
  19.             double totalTime = timeForDistance + delayTime;
  20.  
  21.             if(totalTime < recordInSec)
  22.             {
  23.                 Console.WriteLine($"Yes, he succeeded! The new world record is {totalTime:f2} seconds.");
  24.             }
  25.             else
  26.             {
  27.                 double timeSlowerInSec = totalTime - recordInSec;
  28.                 Console.WriteLine($"No, he failed! He was {timeSlowerInSec:f2} seconds slower.");
  29.             }
  30.         }
  31.     }
  32. }
  33.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement