Advertisement
riff-raff

01. Charity Marathon

Aug 23rd, 2018
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.06 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _01.Charity_Marathon
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int days = int.Parse(Console.ReadLine());
  10.             int participants = int.Parse(Console.ReadLine());
  11.             int averageLaps = int.Parse(Console.ReadLine());
  12.             double trackLength = double.Parse(Console.ReadLine());
  13.             int trackCapacity = int.Parse(Console.ReadLine());
  14.             double moneyPerKm = double.Parse(Console.ReadLine());
  15.  
  16.             int maxCapacity = trackCapacity * days;
  17.             double raisedMoney = 0;
  18.  
  19.             if (maxCapacity > participants)
  20.             {
  21.                 double totalkm = (participants * averageLaps * trackLength)/1000;
  22.                 raisedMoney = totalkm * moneyPerKm;
  23.             }
  24.             else
  25.             {
  26.                 double totalkm = (maxCapacity * averageLaps * trackLength) / 1000;
  27.                 raisedMoney = totalkm * moneyPerKm;
  28.             }
  29.  
  30.  
  31.             Console.WriteLine($"Money raised: {raisedMoney:f2}");
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement