+ Нов въпрос
darrieh 1 Точки

7. Hotel room

Здравейте! Бих искал да попитам защо на първата ми проверка с IF променливите въобще не влизат в нея, а направо смятат резултата все едно няма отстъпка?

Код: https://pastebin.com/M1veHSmV

Тагове:
1
Axiomatik 1469 Точки
``````            string month = Console.ReadLine();
double totalStudio = 0;
double totalApartment = 0;

switch (month)
{
case "May":
totalStudio = nights * 50;
totalApartment = nights * 65;
if (nights > 7)
{
totalStudio = totalStudio * 0.95;

}
else if (nights > 14)
{
totalStudio = totalStudio * 0.70;
totalApartment = totalApartment * 0.90;
}
break;
case "October":
totalStudio = nights * 50;
totalApartment = nights * 65;
if (nights > 7)
{
totalStudio = totalStudio * 0.95;

}
else if (nights > 14)
{
totalStudio = totalStudio * 0.70;
totalApartment = totalApartment * 0.90;
}
break;
default: break;
}

// if validation can not be set up as general scope inside of switch, must be set up after switch in
// order to apply for both cases
//if (nights > 7)
//{
//    totalStudio = totalStudio * 0.95;

//}
//else if (nights > 14)
//{
//    totalStudio = totalStudio * 0.70;
//    totalApartment = totalApartment * 0.90;
//}

if (month == "June" || month == "September")
{
totalStudio = nights * 75.20;
totalApartment = nights * 68.70;
if (nights > 14)
{
totalStudio = totalStudio - (totalStudio * 0.20);
totalApartment = totalApartment - (totalApartment * 0.10);
}
}
else if (month == "July" || month == "August")
{
totalStudio = nights * 76;
totalApartment = nights * 77;
if (nights > 14)
{
totalApartment = totalApartment - (totalApartment * 0.10);
}
}
Console.WriteLine(\$"{totalApartment:f2}");
Console.WriteLine(\$"{totalStudio:f2}");``````

1