Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Diagnostics.CodeAnalysis;
- using System.Linq;
- namespace NonNullablesInCSharp8
- {
- class Program
- {
- static void Main(string[] args)
- {
- char[] separators = { ',', ';', ':', '.', '!', '(', ')', '"', '\'', '\\', '/', '[', ']', ' ', '?'};
- double budget = double.Parse(Console.ReadLine());
- string season = Console.ReadLine();
- Func<double, string> getTheClassName = ReturnTheClassName;
- string className = getTheClassName(budget);
- double percent = GetPercenteOfBudget(season, className);
- string car = GetCar(season, className);
- double totalToPay = budget * percent;
- Console.WriteLine(className + " class");
- Console.Write($"{car} - {totalToPay:f2}");
- }
- public static string GetCar(string season, string className)
- {
- string car = "";
- if(className == "Luxury")
- {
- car = "Jeep";
- }
- else if(className == "Economy")
- {
- switch(season)
- {
- case "Summer":
- car = "Roadster";
- break;
- case "Winter":
- car = "Four-Wheel";
- break;
- default:
- break;
- }
- }
- else if(className == "Compact")
- {
- switch (season)
- {
- case "Summer":
- car = "Roadster";
- break;
- case "Winter":
- car = "Four-Wheel";
- break;
- default:
- break;
- }
- }
- return car;
- }
- public static double GetPercenteOfBudget(string season, string className)
- {
- double percent = 0;
- if(className == "Luxury")
- {
- percent = 0.9;
- }
- else
- {
- if(className == "Economy")
- {
- switch(season)
- {
- case "Summer":
- percent = 0.35;
- break;
- case "Winter":
- percent = 0.45;
- break;
- }
- }
- else if(className == "Compact")
- {
- switch (season)
- {
- case "Summer":
- percent = 0.45;
- break;
- case "Winter":
- percent = 0.80;
- break;
- }
- }
- }
- return percent;
- }
- public static string ReturnTheClassName(double budget)
- {
- string className = "";
- if(budget <= 100)
- {
- className = "Economy";
- }
- else if(budget > 100 && budget <= 500)
- {
- className = "Compact";
- }
- else if(budget > 500)
- {
- className = "Luxury";
- }
- return className;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement