simonradev

Third

Apr 30th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.55 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 BikeRace
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int juniorRacers = int.Parse(Console.ReadLine());
  14.             int seniorRacers = int.Parse(Console.ReadLine());
  15.             string traceType = Console.ReadLine().ToLower();
  16.  
  17.             double juniorTicketPrice = 5.5;
  18.             double seniorTicketPrice = 7.0;
  19.            
  20.             if (traceType == "cross-country")
  21.             {
  22.                 //special case1
  23.                 juniorTicketPrice = 8.0;
  24.                 seniorTicketPrice = 9.5;
  25.  
  26.                 int totalPeopleCount = juniorRacers + seniorRacers;
  27.                 if (totalPeopleCount >= 50)
  28.                 {
  29.                     juniorTicketPrice *= 0.75;
  30.                     seniorTicketPrice *= 0.75;
  31.                 }
  32.             }
  33.             else if (traceType == "downhill")
  34.             {
  35.                 juniorTicketPrice = 12.25;
  36.                 seniorTicketPrice = 13.75;
  37.             }
  38.             else if (traceType == "road")
  39.             {
  40.                 juniorTicketPrice = 20.0;
  41.                 seniorTicketPrice = 21.5;
  42.             }
  43.  
  44.             double totalMoneyEarned = (juniorRacers * juniorTicketPrice) +
  45.                                       (seniorRacers * seniorTicketPrice);
  46.  
  47.             double finalMoneyResult = totalMoneyEarned * 0.95;
  48.  
  49.             Console.WriteLine($"{finalMoneyResult:f2}");
  50.         }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment