Advertisement
StoimenK

C# 2.3 Vacation

Jan 20th, 2020
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.33 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 _2.Vacation
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // First Input Info: 1. group of people (int) - 2. type of the group (string) - 3. which day of the week (string) +++
  14.             /* Second Info: Based on that information calculate how much they have to pay and print that price on the console. Use the table +++
  15.                  Discount:
  16.                 • Students – if the group is bigger than or equal to 30 people you should reduce the total price by 15% +++
  17.                 • Business – if the group is bigger than or equal to  100 people 10 of them can stay for free. +++
  18.                 • Regular – if the group is bigger than or equal to 10 and less than or equal to 20 reduce the total price by 5% */
  19.  
  20.             int groupNum = int.Parse(Console.ReadLine());
  21.             string groupType = Console.ReadLine();
  22.             string day = Console.ReadLine();
  23.  
  24.             decimal price = 0;
  25.            
  26.  
  27.             if (groupType == "Students")
  28.             {
  29.                 if (day == "Friday")
  30.                 {
  31.                     price = 8.45M;
  32.                    
  33.                 }
  34.                 else if (day == "Saturday")
  35.                 {
  36.                     price = 9.80M;
  37.                 }
  38.                 else if (day == "Sunday")
  39.                 {
  40.                     price = 10.46M;
  41.                 }
  42.  
  43.                 if (groupNum < 30)
  44.                 {
  45.                     Console.WriteLine($"Total price: {groupNum * price:F2}");
  46.                 }
  47.                 else
  48.                 {
  49.                     Console.WriteLine($"Total price: {groupNum * price * 0.85M:F2}");
  50.                 }
  51.  
  52.             }
  53.  
  54.             else if (groupType == "Business")
  55.             {
  56.                 if (day == "Friday")
  57.                 {
  58.                     price = 10.90M;
  59.  
  60.                 }
  61.                 else if (day == "Saturday")
  62.                 {
  63.                     price = 15.60M;
  64.                 }
  65.                 else if (day == "Sunday")
  66.                 {
  67.                     price = 16;
  68.                 }
  69.  
  70.                 if (groupNum < 100)
  71.                 {
  72.                     Console.WriteLine($"Total price: {groupNum * price:F2}");
  73.                 }
  74.                 else
  75.                 {
  76.                     Console.WriteLine($"Total price: {(groupNum - 10) * price:F2}");
  77.                 }
  78.             }
  79.  
  80.             else if (groupType == "Regular")
  81.             {
  82.                 if (day == "Friday")
  83.                 {
  84.                     price = 15;
  85.  
  86.                 }
  87.                 else if (day == "Saturday")
  88.                 {
  89.                     price = 20;
  90.                 }
  91.                 else if (day == "Sunday")
  92.                 {
  93.                     price = 22.50M;
  94.                 }
  95.  
  96.                 if (groupNum < 10 || groupNum > 20)
  97.                 {
  98.                     Console.WriteLine($"Total price: {groupNum * price:F2}");
  99.                 }
  100.                 else if (groupNum >= 10 && groupNum <= 20)
  101.                 {
  102.                     Console.WriteLine($"Total price: {groupNum * price * 0.95M:F2}");
  103.                 }
  104.             }
  105.  
  106.         }
  107.     }
  108. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement