ivanitd

Ivan Ivanov

Posted on January 20, 2023

09. Ski Trip
using System;

namespace SkiTrip
{
internal class Program
{
    static void Main(string[] args)
    {
        int stayDays = int.Parse(Console.ReadLine());
        string placeType = Console.ReadLine();
        string rating = Console.ReadLine();

        double pricePerNight = 0.00;
        stayDays = stayDays - 1; // Minus one (1) because it's per night

        // The price discount for each room type
        if (placeType == "room for one person")
        {
            pricePerNight = stayDays * 18.00;

        }
        else if (placeType == "apartment")
        {
            pricePerNight = stayDays * 25.00;

            if (stayDays > 15)
            {
                pricePerNight -= pricePerNight * 0.50;
            }
            else if (stayDays >= 10 && stayDays <= 15)
            {
                pricePerNight -= pricePerNight * 0.35;
            }
            else if (stayDays < 10)
            {
                pricePerNight -= pricePerNight * 0.30;
            }
        }
        else if (placeType == "president apartment")
        {
            pricePerNight = stayDays * 35.00;

            if (stayDays > 15)
            {
                pricePerNight -= pricePerNight * 0.20;
            }
            else if (stayDays >= 10 && stayDays <= 15)
            {
                pricePerNight -= pricePerNight * 0.15;
            }
            else if (stayDays < 10)
            {
                pricePerNight -= pricePerNight * 0.10;
            }
        }

        // The rise and fall depends by the user's rating
        if (rating == "positive")
        {
            pricePerNight += pricePerNight * 0.25;
        }
        else if (rating == "negative")
        {
            pricePerNight -= pricePerNight * 0.10;
        }

        Console.WriteLine($"{pricePerNight:F2}");
    }
}
}
Enter fullscreen mode Exit fullscreen mode
💖 💪 🙅 🚩
ivanitd
Ivan Ivanov

Posted on January 20, 2023

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related

1. Cinema (If Construction)
csharp 1. Cinema (If Construction)

January 20, 2023

09. Ski Trip
csharp 09. Ski Trip

January 20, 2023