Review the solution to the apply business rules challenge activity

Completed

The following code is one possible solution for the challenge from the previous unit.

Random random = new Random();
int daysUntilExpiration = random.Next(12);
int discountPercentage = 0;

if (daysUntilExpiration == 0)
{
    Console.WriteLine("Your subscription has expired.");
}
else if (daysUntilExpiration == 1)
{
    Console.WriteLine("Your subscription expires within a day!");
    discountPercentage = 20;
}
else if (daysUntilExpiration <= 5)
{
    Console.WriteLine($"Your subscription expires in {daysUntilExpiration} days.");
    discountPercentage = 10;
}
else if (daysUntilExpiration <= 10)
{
    Console.WriteLine("Your subscription will expire soon. Renew now!");
}

if (discountPercentage > 0)
{
    Console.WriteLine($"Renew now and save {discountPercentage}%.");
}

This code is merely "one possible solution" because a lot depends on how you decided to implement the logic. As long as you got the right results per the rules in the challenge, and you used two if statements, you did great!

If you're successful, congratulations! Continue on to the knowledge check in the next unit.

Important

If you had trouble completing this challenge, maybe you should review the previous units before you continue on.