Advertisement
Zaksofon

C# Fundamentals - 3. Vacation

Jan 16th, 2021
199
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.50 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03._Vacation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int peopleCount = int.Parse(Console.ReadLine());
  10.             string groupType = Console.ReadLine();
  11.             string weekDay = Console.ReadLine();
  12.  
  13.             double pricePerPerson = 0;
  14.             double total = 0;
  15.  
  16.             switch (groupType)
  17.             {
  18.                 case "Students":
  19.                     switch (weekDay)
  20.                     {
  21.                         case "Friday":
  22.                             pricePerPerson = 8.45;
  23.                             break;
  24.                         case "Saturday":
  25.                             pricePerPerson = 9.80;
  26.                             break;
  27.                         case "Sunday":
  28.                             pricePerPerson = 10.46;
  29.                             break;
  30.                     }
  31.                     break;
  32.                 case "Business":
  33.                     switch (weekDay)
  34.                     {
  35.                         case "Friday":
  36.                             pricePerPerson = 10.90;
  37.                             break;
  38.                         case "Saturday":
  39.                             pricePerPerson = 15.60;
  40.                             break;
  41.                         case "Sunday":
  42.                             pricePerPerson = 16;
  43.                             break;
  44.                     }
  45.                     break;
  46.                 case "Regular":
  47.                     switch (weekDay)
  48.                     {
  49.                         case "Friday":
  50.                             pricePerPerson = 15;
  51.                             break;
  52.                         case "Saturday":
  53.                             pricePerPerson = 20;
  54.                             break;
  55.                         case "Sunday":
  56.                             pricePerPerson = 22.50;
  57.                             break;
  58.                     }
  59.                     break;
  60.             }
  61.             total = peopleCount * pricePerPerson;
  62.             if (groupType == "Students" && peopleCount >= 30)
  63.             {
  64.                 total *= 0.85;
  65.             }
  66.             else if (groupType == "Business" && peopleCount >= 100)
  67.             {
  68.                 peopleCount -= 10;
  69.             }
  70.             else if (groupType == "Regular" && peopleCount >= 10 && peopleCount <= 20)
  71.             {
  72.                 total *= 0.95;
  73.             }
  74.             Console.WriteLine($"Total price: {total:F2}");
  75.         }
  76.     }
  77. }
  78.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement