IvetValcheva

04. Fishing Boat

Jan 23rd, 2022
422
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.46 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _04
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int moneyTotal = int.Parse(Console.ReadLine());
  10.             string season = Console.ReadLine();
  11.             int nFishers = int.Parse(Console.ReadLine());
  12.             double price = 1.00;
  13.  
  14.             switch (season)
  15.             {
  16.                 case "Spring":
  17.                     price = 3000;
  18.                     break;
  19.                 case "Summer":
  20.                 case "Autumn":
  21.                     price = 4200;
  22.                     break;
  23.                 case "Winter":
  24.                     price = 2600;
  25.                     break;
  26.             }
  27.  
  28.             if (nFishers <= 6)
  29.             {
  30.                 price = price - price * 0.1;
  31.             }
  32.             else if (nFishers <= 11)
  33.             {
  34.                 price = price - price * 0.15;
  35.             }
  36.             else if (nFishers >= 12)
  37.             {
  38.                 price = price - price * 0.25;
  39.             }
  40.  
  41.             if (nFishers % 2 == 0 && season != "Autumn")
  42.             {
  43.                 price = price - price * 0.05;
  44.             }
  45.  
  46.             if (moneyTotal >= price)
  47.             {
  48.                 Console.WriteLine($"Yes! You have {moneyTotal - price:F2} leva left.");
  49.             }
  50.             else
  51.             {
  52.                 Console.WriteLine($"Not enough money! You need {price - moneyTotal:F2} leva.");
  53.             }
  54.         }
  55.     }
  56. }
Advertisement
Add Comment
Please, Sign In to add comment