From 7c8c6ac5c59ec7d20caba955534eeb0ed32cfd5a Mon Sep 17 00:00:00 2001 From: Isaac Alter Date: Wed, 19 Jul 2023 19:13:03 -0600 Subject: [PATCH] Add feat: challenge 4 for C# referesher --- .../CsharpProjects/CsharpProjects.csproj | 10 +++++++ .../CsharpProjects/Program.cs | 28 +++++++++++++++++++ 2 files changed, 38 insertions(+) create mode 100644 2-csharp/lesson-2-projects/CsharpProjects/CsharpProjects.csproj create mode 100644 2-csharp/lesson-2-projects/CsharpProjects/Program.cs diff --git a/2-csharp/lesson-2-projects/CsharpProjects/CsharpProjects.csproj b/2-csharp/lesson-2-projects/CsharpProjects/CsharpProjects.csproj new file mode 100644 index 0000000..74abf5c --- /dev/null +++ b/2-csharp/lesson-2-projects/CsharpProjects/CsharpProjects.csproj @@ -0,0 +1,10 @@ + + + + Exe + net6.0 + enable + enable + + + diff --git a/2-csharp/lesson-2-projects/CsharpProjects/Program.cs b/2-csharp/lesson-2-projects/CsharpProjects/Program.cs new file mode 100644 index 0000000..20e01e6 --- /dev/null +++ b/2-csharp/lesson-2-projects/CsharpProjects/Program.cs @@ -0,0 +1,28 @@ +Random random = new Random(); +int daysUntilExpiration = random.Next(12); +int discountPercentage = 0; + +Console.WriteLine(daysUntilExpiration); + +if (daysUntilExpiration <= 10 && daysUntilExpiration > 5) +{ + discountPercentage = 0; + Console.Write("Your subscription will expire soon. Renew now!"); +} +else if (daysUntilExpiration <= 5 && daysUntilExpiration > 1) +{ + discountPercentage = 10; + Console.WriteLine("Your subscription expires in " + daysUntilExpiration + " days."); + Console.Write("Renew now and save " + discountPercentage + "%!"); +} +else if (daysUntilExpiration == 1) +{ + discountPercentage = 20; + Console.WriteLine("Your subscription expires in a day!"); + Console.Write("Renew now and save " + discountPercentage + "%!"); +} +else if (daysUntilExpiration < 1) +{ + discountPercentage = 0; + Console.WriteLine("Your subscription has expired."); +} \ No newline at end of file