Advertisement
NelIfandieva

RentACar_ForDelegateTrials

Feb 11th, 2020
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.55 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics.CodeAnalysis;
  4. using System.Linq;
  5.  
  6. namespace NonNullablesInCSharp8
  7. {
  8.     class Program
  9.     {
  10.         static void Main(string[] args)
  11.         {
  12.             char[] separators = { ',', ';', ':', '.', '!', '(', ')', '"', '\'', '\\', '/', '[', ']', ' ', '?'};
  13.  
  14.             double budget = double.Parse(Console.ReadLine());
  15.             string season = Console.ReadLine();
  16.  
  17.             Func<double, string> getTheClassName = ReturnTheClassName;
  18.             string className = getTheClassName(budget);
  19.             double percent = GetPercenteOfBudget(season, className);
  20.             string car = GetCar(season, className);
  21.             double totalToPay = budget * percent;
  22.  
  23.             Console.WriteLine(className + " class");
  24.             Console.Write($"{car} - {totalToPay:f2}");
  25.         }
  26.  
  27.         public static string GetCar(string season, string className)
  28.         {
  29.             string car = "";
  30.  
  31.             if(className == "Luxury")
  32.             {
  33.                 car = "Jeep";
  34.             }
  35.             else if(className == "Economy")
  36.             {
  37.                 switch(season)
  38.                 {
  39.                     case "Summer":
  40.                         car = "Roadster";
  41.                         break;
  42.                     case "Winter":
  43.                         car = "Four-Wheel";
  44.                         break;
  45.                     default:
  46.                         break;
  47.                 }
  48.             }
  49.             else if(className == "Compact")
  50.             {
  51.                 switch (season)
  52.                 {
  53.                     case "Summer":
  54.                         car = "Roadster";
  55.                         break;
  56.                     case "Winter":
  57.                         car = "Four-Wheel";
  58.                         break;
  59.                     default:
  60.                         break;
  61.                 }
  62.             }
  63.             return car;
  64.         }
  65.  
  66.         public static double GetPercenteOfBudget(string season, string className)
  67.         {
  68.             double percent = 0;
  69.  
  70.             if(className == "Luxury")
  71.             {
  72.                 percent = 0.9;
  73.             }
  74.             else
  75.             {
  76.                 if(className == "Economy")
  77.                 {
  78.                     switch(season)
  79.                     {
  80.                         case "Summer":
  81.                             percent = 0.35;
  82.                             break;
  83.                         case "Winter":
  84.                             percent = 0.45;
  85.                             break;
  86.                     }
  87.                 }
  88.                 else if(className == "Compact")
  89.                 {
  90.                     switch (season)
  91.                     {
  92.                         case "Summer":
  93.                             percent = 0.45;
  94.                             break;
  95.                         case "Winter":
  96.                             percent = 0.80;
  97.                             break;
  98.                     }
  99.                 }
  100.             }
  101.  
  102.             return percent;
  103.         }
  104.  
  105.         public static string ReturnTheClassName(double budget)
  106.         {
  107.             string className = "";
  108.  
  109.             if(budget <= 100)
  110.             {
  111.                 className = "Economy";
  112.             }
  113.             else if(budget > 100 && budget <= 500)
  114.             {
  115.                 className = "Compact";
  116.             }
  117.             else if(budget > 500)
  118.             {
  119.                 className = "Luxury";
  120.             }
  121.  
  122.             return className;
  123.         }
  124.     }
  125. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement