Advertisement
mark79

C# Fundamentals - Vacation

May 21st, 2019
480
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.01 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Vacation
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.  
  10.             int totalPeople = int.Parse(Console.ReadLine());
  11.             string groupType = Console.ReadLine();
  12.             string dayOfWeek = Console.ReadLine();
  13.  
  14.             double pricePerPerson = 0;
  15.             switch (groupType)
  16.             {
  17.                 case "Students":
  18.                     switch (dayOfWeek)
  19.                     {
  20.                         case "Friday": pricePerPerson = 8.45; break;
  21.                         case "Saturday": pricePerPerson = 9.80; break;
  22.                         case "Sunday": pricePerPerson = 10.46; break;
  23.                     }
  24.                     if (totalPeople >= 30)
  25.                     {
  26.                         pricePerPerson *= 0.85;
  27.                     }
  28.                     break;
  29.                 case "Business":
  30.                     switch (dayOfWeek)
  31.                     {
  32.                         case "Friday": pricePerPerson = 10.90; break;
  33.                         case "Saturday": pricePerPerson = 15.60; break;
  34.                         case "Sunday": pricePerPerson = 16.00; break;
  35.                     }
  36.                     if (totalPeople >= 100)
  37.                     {
  38.                         totalPeople -= 10;
  39.                     }
  40.                     break;
  41.                 case "Regular":
  42.                     switch (dayOfWeek)
  43.                     {
  44.                         case "Friday": pricePerPerson = 15.00; break;
  45.                         case "Saturday": pricePerPerson = 20.00; break;
  46.                         case "Sunday": pricePerPerson = 22.50; break;
  47.                     }
  48.                     if (totalPeople >= 10 && totalPeople <= 20)
  49.                     {
  50.                         pricePerPerson *= 0.95;
  51.                     }
  52.                     break;
  53.             }
  54.  
  55.             double totalPrice = totalPeople * pricePerPerson;
  56.             Console.WriteLine($"Total price: {totalPrice:F2}");
  57.  
  58.         }
  59.     }
  60. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement