Advertisement
Guest User

Untitled

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