Created
September 22, 2019 16:43
-
-
Save kkaraivanov/7c7b5b696227678736a73a8564ab927d to your computer and use it in GitHub Desktop.
C# FishingBoat
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
namespace FishingBoat | |
{ | |
class Program | |
{ | |
static void Main(string[] args) | |
{ | |
int groupBudget = int.Parse(Console.ReadLine()); | |
string sezonName = Console.ReadLine(); | |
int fisherManCount = int.Parse(Console.ReadLine()); | |
double rent = 0; | |
double discount = 0; | |
switch (sezonName) | |
{ | |
case "Spring": | |
rent = 3000; | |
if (fisherManCount >= 12) | |
{ | |
discount = rent * 0.25; | |
rent -= discount; | |
} | |
else if (fisherManCount >= 7 && fisherManCount <= 11) | |
{ | |
discount = rent * 0.15; | |
rent -= discount; | |
} | |
else | |
{ | |
discount = rent * 0.10; | |
rent -= discount; | |
} | |
if (fisherManCount % 2 == 0) | |
{ | |
discount = rent * 0.05; | |
rent -= discount; | |
} | |
else | |
{ | |
rent = rent; | |
} | |
break; | |
case "Summer": | |
case "Autumn": | |
rent = 4200; | |
if (fisherManCount >= 12) | |
{ | |
discount = rent * 0.25; | |
rent -= discount; | |
} | |
else if (fisherManCount >= 7 && fisherManCount <= 11) | |
{ | |
discount = rent * 0.15; | |
rent -= discount; | |
} | |
else | |
{ | |
discount = rent * 0.10; | |
rent -= discount; | |
} | |
if (fisherManCount % 2 == 0 && sezonName != "Autumn") | |
{ | |
discount = rent * 0.05; | |
rent -= discount; | |
} | |
else | |
{ | |
rent = rent; | |
} | |
break; | |
case "Winter": | |
rent = 2600; | |
if (fisherManCount >= 12) | |
{ | |
discount = rent * 0.25; | |
rent -= discount; | |
} | |
else if (fisherManCount >= 7 && fisherManCount <= 11) | |
{ | |
discount = rent * 0.15; | |
rent -= discount; | |
} | |
else | |
{ | |
discount = rent * 0.10; | |
rent -= discount; | |
} | |
if (fisherManCount % 2 == 0) | |
{ | |
discount = rent * 0.05; | |
rent -= discount; | |
} | |
else | |
{ | |
rent = rent; | |
} | |
break; | |
} | |
double totalPrice = Math.Abs(groupBudget - rent); | |
if (rent <= groupBudget) | |
{ | |
Console.WriteLine($"Yes! You have {totalPrice:f2} leva left."); | |
} | |
else | |
{ | |
Console.WriteLine($"Not enough money! You need {totalPrice:f2} leva."); | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment