Advertisement
Dianov

Conditional Statements Advanced - Lab (12. Trade Commissions)

Nov 1st, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 3.75 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace TradeCommissions
  8. {
  9.     class Program
  10.     {
  11.         public static void Main()
  12.         {
  13.             string city = Console.ReadLine();
  14.             double sellings = double.Parse(Console.ReadLine());
  15.             double commission;
  16.  
  17.             switch (city)
  18.             {
  19.                 case "Sofia":
  20.                     if (sellings >= 0 && sellings <= 500)
  21.                     {
  22.                         commission = sellings * 0.05;
  23.                         Console.WriteLine("{0:F2}", commission);
  24.                     }
  25.                     else if (sellings > 500 && sellings <= 1000)
  26.                     {
  27.                         commission = sellings * 0.07;
  28.                         Console.WriteLine("{0:F2}", commission);
  29.                     }
  30.                     else if (sellings > 1000 && sellings <= 10000)
  31.                     {
  32.                         commission = sellings * 0.08;
  33.                         Console.WriteLine("{0:F2}", commission);
  34.                     }
  35.                     else if (sellings > 10000)
  36.                     {
  37.                         commission = sellings * 0.12;
  38.                         Console.WriteLine("{0:F2}", commission);
  39.                     }
  40.                     else
  41.                     {
  42.                         Console.WriteLine("error");
  43.                     }
  44.                     break;
  45.                 case "Varna":
  46.                     if (sellings >= 0 && sellings <= 500)
  47.                     {
  48.                         commission = sellings * 0.045;
  49.                         Console.WriteLine("{0:F2}", commission);
  50.                     }
  51.                     else if (sellings > 500 && sellings <= 1000)
  52.                     {
  53.                         commission = sellings * 0.075;
  54.                         Console.WriteLine("{0:F2}", commission);
  55.                     }
  56.                     else if (sellings > 1000 && sellings <= 10000)
  57.                     {
  58.                         commission = sellings * 0.10;
  59.                         Console.WriteLine("{0:F2}", commission);
  60.                     }
  61.                     else if (sellings > 10000)
  62.                     {
  63.                         commission = sellings * 0.13;
  64.                         Console.WriteLine("{0:F2}", commission);
  65.                     }
  66.                     else
  67.                     {
  68.                         Console.WriteLine("error");
  69.                     }
  70.                     break;
  71.                 case "Plovdiv":
  72.                     if (sellings >= 0 && sellings <= 500)
  73.                     {
  74.                         commission = sellings * 0.055;
  75.                         Console.WriteLine("{0:F2}", commission);
  76.                     }
  77.                     else if (sellings > 500 && sellings <= 1000)
  78.                     {
  79.                         commission = sellings * 0.08;
  80.                         Console.WriteLine("{0:F2}", commission);
  81.                     }
  82.                     else if (sellings > 1000 && sellings <= 10000)
  83.                     {
  84.                         commission = sellings * 0.12;
  85.                         Console.WriteLine("{0:F2}", commission);
  86.                     }
  87.                     else if (sellings > 10000)
  88.                     {
  89.                         commission = sellings * 0.145;
  90.                         Console.WriteLine("{0:F2}", commission);
  91.                     }
  92.                     else
  93.                     {
  94.                         Console.WriteLine("error");
  95.                     }
  96.                     break;
  97.                 default:
  98.                     Console.WriteLine("error");
  99.                     break;
  100.             }
  101.         }
  102.     }
  103. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement