bacco

Куриер Експрес : Courier Express

Feb 8th, 2018
169
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.19 KB | None | 0 0
  1. using System;
  2.  
  3. namespace tESt
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             var weight = double.Parse(Console.ReadLine());
  10.             var typeDelivery = (Console.ReadLine().ToLower());
  11.             var km = int.Parse(Console.ReadLine());
  12.  
  13.             double costs = 0;
  14.  
  15.             if (typeDelivery == "standard")
  16.             {
  17.                 if (weight < 1)
  18.                 {
  19.                     costs =  km * 3;
  20.                 }
  21.                 else if (weight <= 10)
  22.                 {
  23.                     costs =  km * 5;
  24.                 }
  25.                 else if (weight <= 40)
  26.                 {
  27.                     costs =  km * 10;
  28.                 }
  29.                 else if (weight <= 90)
  30.                 {
  31.                     costs =  km * 15;
  32.                 }
  33.                 else if (weight <= 150)
  34.                 {
  35.                     costs =  km * 20;
  36.                 }
  37.                 else
  38.                 {
  39.                     Console.WriteLine("Error!");
  40.                 }
  41.             }
  42.             else
  43.             {
  44.                 if (weight < 1)
  45.                 {
  46.  
  47.  
  48.                     costs = km * 3 +  (  weight * km * (3 * 0.80) );  // 80%
  49.  
  50.  
  51.  
  52.                 }
  53.                 else if (weight <= 10)
  54.                 {
  55.                     costs =  km * 5 + (  weight * km * (5 * 0.40));   // 40%
  56.                 }
  57.  
  58.  
  59.  
  60.                 else if (weight <= 40)
  61.                 {
  62.                     costs =  km * 10 + ( weight * km * (10 * 0.05)); // 5%
  63.                 }
  64.  
  65.  
  66.                 else if (weight <= 90)
  67.                 {
  68.                     costs =  km * 15 + ( weight * km * (15 * 0.02));     // 2%
  69.                 }
  70.                 else if (weight <= 150)
  71.                 {
  72.                     costs = km * 20 + ( weight * km * (20 * 0.01)); // 1%
  73.                 }
  74.                 else
  75.                 {
  76.                     Console.WriteLine("Error!");
  77.                 }
  78.             }
  79.  
  80.             costs = costs / 100.0;  // money 0.00
  81.  
  82.             Console.WriteLine($"The delivery of your shipment with weight of {weight:f3} kg. would cost {costs:f2} lv.");
  83.  
  84.         }
  85.     }
  86. }
Advertisement
Add Comment
Please, Sign In to add comment