Advertisement
silvana1303

fishing boat

Mar 29th, 2020
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.13 KB | None | 0 0
  1. using System;
  2.  
  3. namespace homeworkconditional
  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 fishermanCount = int.Parse(Console.ReadLine());
  12.  
  13.             var boatRent = 0.0;
  14.  
  15.             if (season == "Spring")
  16.             {
  17.                 boatRent = 3000.0;
  18.  
  19.                 if (fishermanCount <= 6)
  20.                 {
  21.                     boatRent *= 0.90;
  22.                 }
  23.                 else if (fishermanCount <= 11)
  24.                 {
  25.                     boatRent *= 0.85;
  26.                 }
  27.                 else
  28.                 {
  29.                     boatRent *= 0.75;
  30.                 }
  31.             }
  32.             else if (season == "Summer" || season == "Autumn")
  33.             {
  34.                 boatRent = 4200.0;
  35.  
  36.                 if (fishermanCount <= 6)
  37.                 {
  38.                     boatRent *= 0.90;
  39.                 }
  40.                 else if (fishermanCount <= 11)
  41.                 {
  42.                     boatRent *= 0.85;
  43.                 }
  44.                 else
  45.                 {
  46.                     boatRent *= 0.75;
  47.                 }
  48.             }
  49.             else
  50.             {
  51.                 boatRent = 2600.0;
  52.  
  53.                 if (fishermanCount <= 6)
  54.                 {
  55.                     boatRent *= 0.90;
  56.                 }
  57.                 else if (fishermanCount <= 11)
  58.                 {
  59.                     boatRent *= 0.85;
  60.                 }
  61.                 else
  62.                 {
  63.                     boatRent *= 0.75;
  64.                 }
  65.             }
  66.  
  67.             if (fishermanCount % 2 == 0 && season != "Autumn")
  68.             {
  69.                 boatRent *= 0.95;
  70.             }
  71.  
  72.             double moneyLeft = budget - boatRent;
  73.  
  74.             if (moneyLeft >= 0)
  75.             {
  76.                 Console.WriteLine($"Yes! You have {moneyLeft:f2} leva left.");
  77.             }
  78.             else
  79.             {
  80.                 Console.WriteLine($"Not enough money! You need {(moneyLeft * -1):F2} leva.");
  81.             }
  82.         }
  83.     }
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement