IvetValcheva

World Swimming Record

Apr 12th, 2021
257
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.83 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp10
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             double record = double.Parse(Console.ReadLine());
  10.             double distance = double.Parse(Console.ReadLine());
  11.             double speed = double.Parse(Console.ReadLine());
  12.  
  13.             double time = distance * speed;
  14.  
  15.             time += Math.Floor(distance/15)*12.5;
  16.  
  17.             double difference = record - time;
  18.  
  19.             if (difference <= 0)
  20.             {
  21.                 difference = Math.Abs(difference);
  22.                 Console.WriteLine($"No, he failed! He was {difference:F2} seconds slower.");
  23.             }
  24.             else
  25.             {
  26.                 Console.WriteLine($"Yes, he succeeded! The new world record is {time:F2} seconds.");
  27.             }
  28.         }
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment