Advertisement
koksibg

Logistics

Mar 5th, 2017
1,185
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.82 KB | None | 0 0
  1. using System;
  2.  
  3. namespace Logistics
  4. {
  5.     class Logistics
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int TheNumberOfCargo = int.Parse(Console.ReadLine());
  10.             double priceMiniBus = 0;
  11.             double priceТruck = 0;
  12.             double priceTrain = 0;
  13.             double sumCargoMiniBus = 0;
  14.             double sumCargoТruck = 0;
  15.             double sumCargoTrain = 0;
  16.             double sumCargo = 0;
  17.             for (int i = 1; i <= TheNumberOfCargo; i++)
  18.             {
  19.                 int theTonnageOfCargo = int.Parse(Console.ReadLine());
  20.                 sumCargo += theTonnageOfCargo;
  21.                 if (theTonnageOfCargo <= 3)
  22.                 {
  23.                     sumCargoMiniBus += theTonnageOfCargo;
  24.                     priceMiniBus += theTonnageOfCargo * 200;
  25.                 }
  26.                 if (theTonnageOfCargo > 3 && theTonnageOfCargo <= 11)
  27.                 {
  28.                     sumCargoТruck += theTonnageOfCargo;
  29.                     priceТruck += theTonnageOfCargo * 175;
  30.                 }
  31.                 if (theTonnageOfCargo > 11)
  32.                 {
  33.                     sumCargoTrain += theTonnageOfCargo;
  34.                     priceTrain += theTonnageOfCargo * 120;
  35.                 }
  36.             }
  37.             double sumAveragePrice = (priceMiniBus + priceТruck + priceTrain) / sumCargo;
  38.             double percentCargoMinibus = sumCargoMiniBus / sumCargo * 100;
  39.             double percentCargoTruck = sumCargoТruck / sumCargo * 100;
  40.             double percentCargoTrain = sumCargoTrain / sumCargo * 100;
  41.             Console.WriteLine($"{sumAveragePrice:f2}");
  42.             Console.WriteLine($"{percentCargoMinibus:f2}%");
  43.             Console.WriteLine($"{percentCargoTruck:f2}%");
  44.             Console.WriteLine($"{percentCargoTrain:f2}%");
  45.         }
  46.     }
  47. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement