IvetValcheva

04. Fishing Boat

Nov 15th, 2021
230
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.87 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp2
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int budget = int.Parse(Console.ReadLine());
  10.             string season = Console.ReadLine();
  11.             int fishermen = int.Parse(Console.ReadLine());
  12.  
  13.             double price = 0.00;
  14.             //"Spring" = 3000, ("Summer", "Autumn") = 4200, "Winter"=2600
  15.  
  16.             switch (season)
  17.             {
  18.                 case "Spring":
  19.                     price = 3000.00;
  20.                     break;
  21.                 case "Summer":
  22.                 case "Autumn":
  23.                     price = 4200.00;
  24.                         break;
  25.                 case "Winter":
  26.                     price = 2600.00;
  27.                     break;
  28.                 default:
  29.                     break;
  30.             }
  31.  
  32.             //до 6 човека включително =10%
  33.             //до 11 човека включително=15%
  34.             //от 12 нагоре = 25%
  35.             if (fishermen <= 6)
  36.             {
  37.                 price -= price * 0.10;
  38.             }
  39.             else if(fishermen <= 11)
  40.             {
  41.                 price -= price * 0.15;
  42.             }
  43.             else
  44.             {
  45.                 price -= price * 0.25;
  46.             }
  47.  
  48.             //ако броят на рибарите  е четен и  !"Autumn" = 5%
  49.             if (fishermen % 2 == 0 && season!= "Autumn")
  50.             {
  51.                 price -= price * 0.05;
  52.             }
  53.  
  54.             //дали бюджета е достатъчен
  55.             if (budget >= price)
  56.             {
  57.                 Console.WriteLine($"Yes! You have {(budget-price):F2} leva left.");
  58.             }
  59.             else
  60.             {
  61.                 Console.WriteLine($"Not enough money! You need {(price-budget):F2} leva.");
  62.             }
  63.  
  64.         }
  65.     }
  66. }
  67.  
Advertisement
Add Comment
Please, Sign In to add comment