Advertisement
Valantina

MountainRun/Exam

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