Skip to content

Instantly share code, notes, and snippets.

@Vladedev Vladedev/Program.cs
Created Jan 24, 2018

Embed
What would you like to do?
04 Hotel
using System;
namespace _04_Hotel
{
class Program
{
static void Main(string[] args)
{
decimal priceForStudio = 0m;
decimal priceForDouble = 0m;
decimal priceForSuite = 0m;
//input
string month = Console.ReadLine().ToLower();
double nightsCount = double.Parse(Console.ReadLine());
//calculation
switch (month)
{
case "may":
case "october":
priceForStudio = 50m;
priceForDouble = 65m;
priceForSuite = 75m;
break;
case "june":
case "september":
priceForStudio = 60m;
priceForDouble = 72m;
priceForSuite = 82m;
break;
case "july":
case "august":
case "december":
priceForStudio = 68m;
priceForDouble = 77m;
priceForSuite = 89m;
break;
}
priceForStudio*= (decimal)nightsCount;
priceForDouble *= (decimal)nightsCount;
priceForSuite *= (decimal)nightsCount;
if (nightsCount > 14)
{
switch (month)
{
case "june":
case "september":
priceForDouble = 72m * 0.9m * (decimal)nightsCount;
break;
case "july":
case "august":
case "december":
priceForSuite = 89m * 0.85m * (decimal)nightsCount;
break;
}
}
if (nightsCount > 7)
{
switch (month)
{
case "may":
priceForStudio = 50m * 0.95m * (decimal)nightsCount;
break;
case "october":
priceForStudio = 50m * 0.95m * (decimal)(nightsCount - 1);
break;
case "september":
priceForStudio = 60m *(decimal)(nightsCount - 1);
break;
}
}
//output
Console.WriteLine($"Studio: {priceForStudio:f2} lv.");
Console.WriteLine($"Double: {priceForDouble:f2} lv.");
Console.WriteLine($"Suite: {priceForSuite:f2} lv.");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.