Advertisement
NelIfandieva

TourDeFrance_Exercise03_26Nov2019

Nov 27th, 2019
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Tour_de_France
  4. {
  5.     class Program
  6.     {
  7.         static void Main()
  8.         {
  9.             int juniors = int.Parse(Console.ReadLine());
  10.             int seniors = int.Parse(Console.ReadLine());
  11.             string roadType = Console.ReadLine();
  12.  
  13.             double singleJuniorPrice = 0;
  14.             double singleSeniorPrice = 0;
  15.  
  16.             int allParticipants = juniors + seniors;
  17.  
  18.             if(roadType == "trail")
  19.             {
  20.                 singleJuniorPrice = 5.50;
  21.                 singleSeniorPrice = 7;
  22.             }
  23.             else if(roadType == "cross-country")
  24.             {
  25.                 singleJuniorPrice = 8;
  26.                 singleSeniorPrice = 9.50;
  27.  
  28.                 if(allParticipants >= 50)
  29.                 {
  30.                     singleJuniorPrice -= singleJuniorPrice * 0.25;
  31.                     singleSeniorPrice -= singleSeniorPrice * 0.25;
  32.                 }
  33.             }
  34.             else if(roadType == "downhill")
  35.             {
  36.                 singleJuniorPrice = 12.25;
  37.                 singleSeniorPrice = 13.75;
  38.             }
  39.             else if(roadType == "road")
  40.             {
  41.                 singleJuniorPrice = 20;
  42.                 singleSeniorPrice = 21.50;
  43.             }
  44.  
  45.             double totalFromJuniors = juniors * singleJuniorPrice;
  46.             double totalFromSeniors = seniors * singleSeniorPrice;
  47.             double totalAmountBeforeTax = totalFromJuniors + totalFromSeniors;
  48.             double tax = totalAmountBeforeTax * 0.05;
  49.             double totalAfterTax = totalAmountBeforeTax - tax;
  50.  
  51.             Console.Write("{0:f2}", totalAfterTax);
  52.         }
  53.     }
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement