Advertisement
Dianov

Basic Syntax, Conditional Statements and Loops - Exercise (03. Vacation)

Mar 26th, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 4.28 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 Vacation
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.  
  14.             int peopleGoing = int.Parse(Console.ReadLine());
  15.             string groupType = Console.ReadLine();
  16.             string day = Console.ReadLine();
  17.  
  18.             decimal priceForStudents;
  19.             decimal priceForBusiness;
  20.             decimal priceForRegular;
  21.             decimal totalPrice;
  22.  
  23.             if (groupType == "Students" && day == "Friday")
  24.             {
  25.                 priceForStudents = 8.45m;
  26.                 totalPrice = peopleGoing * priceForStudents;
  27.                 if (peopleGoing >= 30)
  28.                 {
  29.                     totalPrice = totalPrice - (totalPrice * 0.15m);
  30.                 }
  31.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  32.             }
  33.             else if (groupType == "Students" && day == "Saturday")
  34.             {
  35.                 priceForStudents = 9.80m;
  36.                 totalPrice = peopleGoing * priceForStudents;
  37.                 if (peopleGoing >= 30)
  38.                 {
  39.                     totalPrice = totalPrice - (totalPrice * 0.15m);
  40.                 }
  41.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  42.             }
  43.             else if (groupType == "Students" && day == "Sunday")
  44.             {
  45.                 priceForStudents = 10.46m;
  46.                 totalPrice = peopleGoing * priceForStudents;
  47.                 if (peopleGoing >= 30)
  48.                 {
  49.                     totalPrice = totalPrice - (totalPrice * 0.15m);
  50.                 }
  51.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  52.             }
  53.  
  54.             if (groupType == "Business" && day == "Friday")
  55.             {
  56.                 priceForBusiness = 10.90m;
  57.                 totalPrice = peopleGoing * priceForBusiness;
  58.                 if (peopleGoing >= 100)
  59.                 {
  60.                     totalPrice = totalPrice - (10 * priceForBusiness);
  61.                 }
  62.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  63.             }
  64.             else if (groupType == "Business" && day == "Saturday")
  65.             {
  66.                 priceForBusiness = 15.60m;
  67.                 totalPrice = peopleGoing * priceForBusiness;
  68.                 if (peopleGoing >= 100)
  69.                 {
  70.                     totalPrice = totalPrice - (10 * priceForBusiness);
  71.                 }
  72.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  73.             }
  74.             else if (groupType == "Business" && day == "Sunday")
  75.             {
  76.                 priceForBusiness = 16.00m;
  77.                 totalPrice = peopleGoing * priceForBusiness;
  78.                 if (peopleGoing >= 100)
  79.                 {
  80.                     totalPrice = totalPrice - (10 * priceForBusiness);
  81.                 }
  82.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  83.             }
  84.  
  85.             if (groupType == "Regular" && day == "Friday")
  86.             {
  87.                 priceForRegular = 15.00m;
  88.                 totalPrice = peopleGoing * priceForRegular;
  89.                 if (peopleGoing >= 10 && peopleGoing <= 20)
  90.                 {
  91.                     totalPrice = totalPrice - (totalPrice * 0.05m);
  92.                 }
  93.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  94.             }
  95.             else if (groupType == "Regular" && day == "Saturday")
  96.             {
  97.                 priceForRegular = 20.00m;
  98.                 totalPrice = peopleGoing * priceForRegular;
  99.                 if (peopleGoing >= 10 && peopleGoing <= 20)
  100.                 {
  101.                     totalPrice = totalPrice - (totalPrice * 0.05m);
  102.                 }
  103.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  104.             }
  105.             else if (groupType == "Regular" && day == "Sunday")
  106.             {
  107.                 priceForRegular = 22.50m;
  108.                 totalPrice = peopleGoing * priceForRegular;
  109.                 if (peopleGoing >= 10 && peopleGoing <= 20)
  110.                 {
  111.                     totalPrice = totalPrice - (totalPrice * 0.05m);
  112.                 }
  113.                 Console.WriteLine($"Total price: {totalPrice:F2}");
  114.             }
  115.         }
  116.     }
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement