simonradev

AS

Dec 7th, 2016
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace CharityMarathon
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             decimal days = decimal.Parse(Console.ReadLine());
  14.             decimal runners = decimal.Parse(Console.ReadLine());
  15.             decimal averageLapsPerRunner = decimal.Parse(Console.ReadLine());
  16.             decimal lenghtOfTheTrack = decimal.Parse(Console.ReadLine());
  17.             decimal capacityOfTheTrack = decimal.Parse(Console.ReadLine());
  18.             decimal moneyDonatedPerKilometer = decimal.Parse(Console.ReadLine());
  19.  
  20.             decimal capacityOfTheTrackCalculation = capacityOfTheTrack * days;
  21.  
  22.             if (capacityOfTheTrackCalculation < runners)
  23.             {
  24.                 runners = capacityOfTheTrack;
  25.             }
  26.  
  27.  
  28.             decimal totalMeters = runners * averageLapsPerRunner * lenghtOfTheTrack;
  29.             decimal totalKilometers = totalMeters / 1000.0m;
  30.             decimal moneyRaisedForTheMarathon = totalKilometers * moneyDonatedPerKilometer;
  31.  
  32.             Console.WriteLine($"Money raised: {moneyRaisedForTheMarathon:f2}");
  33.         }
  34.     }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment