Advertisement
Guest User

Untitled

a guest
Feb 19th, 2020
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.78 KB | None | 0 0
  1. using System;
  2.  
  3. namespace WorldSwimmingRecord
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             //1. read input - досегашен рекорд е секунди, разстоянието в метри, което трябва да се преплува,
  10.             // времето в секунди, за което той плува 1 м.
  11.             //2. изчисляваме за колко време ще преплува нуцното разстояние  в сек. - нужните метри* секундите за метър
  12.             //3. добавяме 12.5 сек  към всеки 15 м. => разстоянието в метри/15 * 12.5
  13.             //4 . общото време за преплуване -> т.2. + т.3
  14.             //5. проверка дали т.4 е по-голяма или по малка от входа с рекорда
  15.             //6. печат
  16.  
  17.             double currentRecord = double.Parse(Console.ReadLine());
  18.             double needMeters = double.Parse(Console.ReadLine());
  19.             double timePerMeter = double.Parse(Console.ReadLine());
  20.  
  21.             double timeForSwimming = needMeters * timePerMeter;
  22.             double addSeconds = Math.Floor(needMeters / 15) * 12.5;
  23.             double totalTimeForSwimming = timeForSwimming + addSeconds;
  24.  
  25.  
  26.             if (currentRecord <= totalTimeForSwimming)
  27.             {
  28.                 double isFailed = totalTimeForSwimming - currentRecord;
  29.                 Console.WriteLine($"No, he failed! He was {isFailed:F2} seconds slower.");
  30.             }
  31.             else
  32.             {
  33.                 Console.WriteLine($"Yes, he succeeded! The new world record is {totalTimeForSwimming:F2} seconds.");
  34.             }
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement