Ledger Nano X - The secure hardware wallet
SHARE
TWEET

logistics

silvana1303 Apr 3rd, 2020 226 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. using System;
  2.  
  3. namespace homeworkforloop
  4. {
  5.     class Program
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int logisticCount = int.Parse(Console.ReadLine());
  10.  
  11.             double busPrice = 0.0;
  12.             double truckPrice = 0.0;
  13.             double trainPrice = 0.0;
  14.             var averagePrice = 0.0;
  15.  
  16.             var busWeight = 0.0;
  17.             var truckWeight = 0.0;
  18.             var trainWeight = 0.0;
  19.  
  20.  
  21.             for (int i = 1; i <= logisticCount; i++)
  22.             {
  23.                 int logisticWeight = int.Parse(Console.ReadLine());
  24.  
  25.                
  26.  
  27.                 if (logisticWeight <= 3)
  28.                 {
  29.                     busWeight += logisticWeight;
  30.                     busPrice = busWeight * 200.0;
  31.                 }
  32.                 else if (logisticWeight <= 11)
  33.                 {
  34.                     truckWeight += logisticWeight;
  35.                     truckPrice = truckWeight * 175.0;
  36.                 }
  37.                 else
  38.                 {
  39.                     trainWeight += logisticWeight;
  40.                     trainPrice = trainWeight * 120.0;
  41.                 }
  42.  
  43.                
  44.             }
  45.  
  46.             var totalWeight = busWeight + truckWeight + trainWeight;
  47.  
  48.             averagePrice = (busPrice + truckPrice + trainPrice) / totalWeight;
  49.             var busPercent = (busWeight / totalWeight) * 100.0;
  50.             var truckPercent = (truckWeight / totalWeight) * 100.0;
  51.             var trainPercent = (trainWeight / totalWeight) * 100.0;
  52.  
  53.             Console.WriteLine($"{averagePrice:f2}");
  54.             Console.WriteLine($"{busPercent:f2}%");
  55.             Console.WriteLine($"{truckPercent:f2}%");
  56.             Console.WriteLine($"{trainPercent:f2}%");
  57.  
  58.  
  59.         }
  60.     }
  61. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Top