Advertisement
alexbancheva

Fisging_Boat

Jan 28th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.92 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.             int budget = int.Parse(Console.ReadLine());
  10.             string season = Console.ReadLine();
  11.             int numFishers = int.Parse(Console.ReadLine());
  12.  
  13.             bool flag = true;
  14.             double boatRent = 0;
  15.             double totalPrice = 0;
  16.  
  17.             switch (season)
  18.             {
  19.                 case "Spring":
  20.                     boatRent = 3000;
  21.                     break;
  22.                 case "Summer":
  23.                     boatRent = 4200;
  24.                     break;
  25.                 case "Autumn":
  26.                     boatRent = 4200;
  27.                     break;
  28.                 case "Winter":
  29.                     boatRent = 2600;
  30.                     break;
  31.                 default:
  32.                     flag = false;
  33.                     break;
  34.             }
  35.  
  36.             if (flag)
  37.             {
  38.                 if (numFishers <= 6)
  39.                 {
  40.                     totalPrice = boatRent - 0.1 * boatRent;
  41.                 }
  42.                 else if (numFishers >= 7 && numFishers <= 11)
  43.                 {
  44.                     totalPrice = boatRent - 0.15 * boatRent;
  45.                 }
  46.                 else if (numFishers >= 12)
  47.                 {
  48.                     totalPrice = boatRent - 0.25 * boatRent;
  49.                 }
  50.  
  51.                 if (numFishers % 2 == 0 && season != "Autumn")
  52.                 {
  53.                     totalPrice = totalPrice - 0.05 * totalPrice;
  54.                 }
  55.  
  56.                 if (budget >= totalPrice)
  57.                 {
  58.                     Console.WriteLine($"Yes! You have {budget - totalPrice:f2} leva left.");
  59.                 }
  60.                 else
  61.                 {
  62.                     Console.WriteLine($"Not enough money! You need {totalPrice - budget} leva.");
  63.                 }
  64.             }
  65.         }  
  66.     }
  67. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement