SkiTrip - Programming basics with C#
using System;
namespace SkiTrip
{
class Program
{
static void Main(string[] args)
{
int days = int.Parse(Console.ReadLine());
string room = Console.ReadLine();
string opinion = Console.ReadLine();
int nights = days - 1;
double price = 0;
if (room == "room for one person")
{
price = nights * 18;
}
else if (room == "apartment")
{
price = nights * 25; //total price
if (nights < 10)
{
price = price - 0.3 * price; // 0.7 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.35 * price; // 0.65 * price
}
else if (nights > 15)
{
price = price - price * 0.5; //0.5 * price
}
}
else if (room == "president apartment")
{
price = nights * 35;
if (nights < 10)
{
price = price - 0.10 * price; //0.9 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.15 * price; //0.85 * price
}
else if (nights > 15)
{
price = price * 0.2; // 0.8 * price
}
if (opinion == "positive")
{
price = price + 0.25 * price; //1.25 * price
}
else if (opinion == "negative")
{
price = price - 0.10 * price; //0.9 *price
}
Console.WriteLine($"{price:F2}");
}
}
}
}using System;
namespace SkiTrip
{
class Program
{
static void Main(string[] args)
{
int days = int.Parse(Console.ReadLine());
string room = Console.ReadLine();
string opinion = Console.ReadLine();
int nights = days - 1;
double price = 0;
if (room == "room for one person")
{
price = nights * 18;
}
else if (room == "apartment")
{
price = nights * 25; //total price
if (nights < 10)
{
price = price - 0.3 * price; // 0.7 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.35 * price; // 0.65 * price
}
else if (nights > 15)
{
price = price - price * 0.5; //0.5 * price
}
}
else if (room == "president apartment")
{
price = nights * 35;
if (nights < 10)
{
price = price - 0.10 * price; //0.9 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.15 * price; //0.85 * price
}
else if (nights > 15)
{
price = price * 0.2; // 0.8 * price
}
if (opinion == "positive")
{
price = price + 0.25 * price; //1.25 * price
}
else if (opinion == "negative")
{
price = price - 0.10 * price; //0.9 *price
}
Console.WriteLine($"{price:F2}");
}
}
}
}using System;
namespace SkiTrip
{
class Program
{
static void Main(string[] args)
{
int days = int.Parse(Console.ReadLine());
string room = Console.ReadLine();
string opinion = Console.ReadLine();
int nights = days - 1;
double price = 0;
if (room == "room for one person")
{
price = nights * 18;
}
else if (room == "apartment")
{
price = nights * 25; //total price
if (nights < 10)
{
price = price - 0.3 * price; // 0.7 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.35 * price; // 0.65 * price
}
else if (nights > 15)
{
price = price - price * 0.5; //0.5 * price
}
}
else if (room == "president apartment")
{
price = nights * 35;
if (nights < 10)
{
price = price - 0.10 * price; //0.9 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.15 * price; //0.85 * price
}
else if (nights > 15)
{
price = price * 0.2; // 0.8 * price
}
if (opinion == "positive")
{
price = price + 0.25 * price; //1.25 * price
}
else if (opinion == "negative")
{
price = price - 0.10 * price; //0.9 *price
}
Console.WriteLine($"{price:F2}");
}
}
}
}using System;
namespace SkiTrip
{
class Program
{
static void Main(string[] args)
{
int days = int.Parse(Console.ReadLine());
string room = Console.ReadLine();
string opinion = Console.ReadLine();
int nights = days - 1;
double price = 0;
if (room == "room for one person")
{
price = nights * 18;
}
else if (room == "apartment")
{
price = nights * 25; //total price
if (nights < 10)
{
price = price - 0.3 * price; // 0.7 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.35 * price; // 0.65 * price
}
else if (nights > 15)
{
price = price - price * 0.5; //0.5 * price
}
}
else if (room == "president apartment")
{
price = nights * 35;
if (nights < 10)
{
price = price - 0.10 * price; //0.9 * price
}
else if (nights >= 10 && nights <= 15)
{
price = price - 0.15 * price; //0.85 * price
}
else if (nights > 15)
{
price = price * 0.2; // 0.8 * price
}
if (opinion == "positive")
{
price = price + 0.25 * price; //1.25 * price
}
else if (opinion == "negative")
{
price = price - 0.10 * price; //0.9 *price
}
Console.WriteLine($"{price:F2}");
}
}
}
}
Здравейте, при проверката на президетски апартамент ми дава различен резултат.И получавам 70 т в Джъдж.