Advertisement
MARINA_GREBENAROVA

Fishing_Boat

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