Задача 10.Hotel Room
Здравейте,
Judge-a дава 80 на кода, а всички проверки излизат:
namespace HotelRoom
{
class Program
{
static void Main(string[] args)
{
string month = Console.ReadLine();
int nightsNumber = int.Parse(Console.ReadLine());
double priceStayStudio = 0;
double priceStayApartment = 0;
if (month == "May" || month == "October")
{
priceStayApartment = nightsNumber * 65;
priceStayStudio = nightsNumber * 50;
if (nightsNumber > 7 && nightsNumber <=14)
{
priceStayStudio = nightsNumber *(50*0.95);
}
else if (nightsNumber > 14)
{
priceStayStudio = nightsNumber * (50 * 0.70);
}
if (nightsNumber > 14)
{
priceStayApartment = nightsNumber * (65 * 0.90);
}
}
else if (month == "June" || month == "September")
{
priceStayApartment = nightsNumber * 68.70;
priceStayStudio = nightsNumber * 75.20;
if (nightsNumber > 14)
{
priceStayStudio = nightsNumber * (75.20 * 0.80);
priceStayApartment = nightsNumber * (68.70 * 0.90);
}
}
else if (month == "July" || month == "August")
{
priceStayStudio = nightsNumber * 76;
priceStayApartment = nightsNumber * 77;
if (nightsNumber > 14)
{
priceStayApartment = nightsNumber * (77 * 0.90);
}
}
Console.WriteLine($"Apartment: {priceStayApartment:f2} lv.");
Console.WriteLine($"Studio: {priceStayStudio:f2} lv.");
}
}
}
Здравейте,може ли малко помощ.
Judge-a дава 90 на кода, а всички проверки излизат:
using System;
namespace _07._Hotel_Room
{
class Program
{
static void Main()
{
string month = Console.ReadLine();
double nightsNum = double.Parse(Console.ReadLine());
double apartmentPrice = 0;
double studioPrice = 0;
if (month == "May" || month == "October")
{
if(nightsNum >= 7 && nightsNum <=14)
{
apartmentPrice = 65 * nightsNum;
studioPrice = (50 - (50 * 0.05)) * nightsNum;
}
else //if(nightsNum > 14)
{
apartmentPrice = (65 - (65 * 0.10)) * nightsNum;
studioPrice = (50 - (50 * 0.30)) * nightsNum;
}
}
else if(month == "June" || month == "September")
{
if(nightsNum > 14)
{
apartmentPrice = (68.70 - (68.70 * 0.10)) * nightsNum;
studioPrice = (75.20 - (75.20 * 0.20)) * nightsNum;
}
else
{
apartmentPrice = 68.70 * nightsNum;
studioPrice = 75.20 * nightsNum;
}
}
else if(month == "July" || month == "August")
{
if(nightsNum >14)
{
studioPrice = 76 * nightsNum;
apartmentPrice = (77 - (77 * 0.10)) * nightsNum;
}
else
{
studioPrice = 76 * nightsNum;
apartmentPrice = 77 * nightsNum;
}
}
Console.WriteLine($"Apartment: {apartmentPrice:f2} lv.");
Console.WriteLine($"Studio: {studioPrice:f2} lv.");
}
}
}