Guest User

Untitled

a guest
Oct 23rd, 2016
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.00 KB | None | 0 0
  1. using System;
  2.  
  3. namespace CharityMarathon
  4. {
  5.     public class CharityMarathon
  6.     {
  7.         public static void Main()
  8.         {
  9.             int marathonLength = int.Parse(Console.ReadLine());
  10.             int numOfRunners = int.Parse(Console.ReadLine());
  11.             int numLapsperRunner = int.Parse(Console.ReadLine());
  12.             int trackLength = int.Parse(Console.ReadLine());
  13.             int trackCapacity = int.Parse(Console.ReadLine());
  14.             decimal moneyPerKm = decimal.Parse(Console.ReadLine());
  15.  
  16.             int capacityTotal = trackCapacity * marathonLength;
  17.  
  18.             if (capacityTotal <= numOfRunners)
  19.             {
  20.                 numOfRunners = capacityTotal;
  21.             }
  22.  
  23.             ulong metersTotal = (ulong)numOfRunners * (ulong)numLapsperRunner * (ulong)trackLength;
  24.             ulong totalKm = metersTotal / 1000;
  25.  
  26.             decimal moneyTotal = totalKm * moneyPerKm;
  27.  
  28.             Console.WriteLine("Money raised: {0:f2}", moneyTotal);
  29.  
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment