Advertisement
IvanBorisovG

Logistics

Dec 5th, 2017
165
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.44 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 Logistics
  8. {
  9.     class Logistics
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int loadCount = int.Parse(Console.ReadLine());
  14.             int allLoads = 0;
  15.             double avrPrice = 0;
  16.             int byMinibus = 0;
  17.             int byTruck = 0;
  18.             int byTrain = 0;
  19.             for (int i = 1; i <= loadCount; i++)
  20.             {
  21.                 int LoadTonnage = int.Parse(Console.ReadLine());
  22.                 allLoads += LoadTonnage;
  23.                 if (LoadTonnage < 4)
  24.                 {
  25.                     avrPrice += LoadTonnage * 200;
  26.                     byMinibus += LoadTonnage;
  27.                 }
  28.                 else if (LoadTonnage < 12)
  29.                 {
  30.                     avrPrice += LoadTonnage * 175;
  31.                     byTruck += LoadTonnage;
  32.                 }
  33.                 else
  34.                 {
  35.                     avrPrice += LoadTonnage * 120;
  36.                     byTrain += LoadTonnage;
  37.                 }
  38.             }
  39.             double avrPerTon = avrPrice / allLoads;
  40.             Console.WriteLine($"{avrPerTon:f2}");
  41.             Console.WriteLine($"{byMinibus * 100.0 / allLoads:f2}%");
  42.             Console.WriteLine($"{byTruck * 100.0 / allLoads:f2}%");
  43.             Console.WriteLine($"{byTrain * 100.0 / allLoads:f2}%");
  44.         }
  45.     }
  46. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement