Advertisement
tsvetelinapasheva

TsvetelinaPasheva/ConditionalStatementsAdvancedExercise/04.FishingBoat

Jan 30th, 2021
97
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp8
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.          
  10.             double priceForSpring = 3000;
  11.             double priceForSummerAndAutumn = 4200;
  12.             double priceForWinter = 2600;
  13.  
  14.            
  15.             int budget = int.Parse(Console.ReadLine());
  16.             string season = Console.ReadLine();
  17.             int countOfFisherman = int.Parse(Console.ReadLine());
  18.             double totalMoney = 0;
  19.  
  20.  
  21.  
  22.            
  23.  
  24.             switch (season)
  25.             {
  26.                 case "Winter":
  27.                     totalMoney = priceForWinter;
  28.                     break;                    
  29.                 case "Spring":
  30.                     totalMoney = priceForSpring;
  31.                     break;
  32.                 case "Summer":
  33.                     totalMoney = priceForSummerAndAutumn;
  34.                     break;
  35.                 case "Autumn":
  36.                     totalMoney = priceForSummerAndAutumn;
  37.                     break;
  38.  
  39.             }
  40.  
  41.            
  42.             if (countOfFisherman <= 6)
  43.             {
  44.                 totalMoney = totalMoney - (totalMoney * 0.10);
  45.             }
  46.             else if (countOfFisherman >= 7 && countOfFisherman <= 11)
  47.             {
  48.                 totalMoney = totalMoney - (totalMoney * 0.15);
  49.             }
  50.             else if (countOfFisherman >= 12)
  51.             {
  52.                 totalMoney = totalMoney - (totalMoney * 0.25);
  53.  
  54.             }
  55.  
  56.             if (countOfFisherman % 2 == 0 && season != "Autumn")
  57.             {
  58.                 totalMoney = totalMoney - (totalMoney * 0.05);
  59.             }
  60.  
  61.  
  62.  
  63.             if (budget >= totalMoney)
  64.             {
  65.                 double moneyLeft = budget - totalMoney;
  66.                 Console.WriteLine($"Yes! You have {moneyLeft:f2} leva left.");
  67.             }
  68.             else if (budget < totalMoney)
  69.             {
  70.                 double moneyNeeded = totalMoney - budget;
  71.                 Console.WriteLine($"Not enough money! You need {moneyNeeded:f2} leva.");
  72.             }
  73.         }
  74.     }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement