Advertisement
AleksandarGG

Logistic

Aug 17th, 2017
764
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.73 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 _04.Logistics
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int transports = int.Parse(Console.ReadLine());
  14.  
  15.             double microbus = 0.0;
  16.             double truck = 0.0;
  17.             double train = 0.0;
  18.             double sumTons = 0.0;
  19.  
  20.             double tonsMicrobus = 0.0;
  21.             double tonsTruck = 0.0;
  22.             double tonsTrain = 0.0;
  23.             double avarageTons = 0.0;
  24.  
  25.             for (int i = 1; i <= transports; i++)
  26.             {
  27.                 int tons = int.Parse(Console.ReadLine());
  28.  
  29.                 if (tons <= 3)
  30.                 {
  31.                     microbus = tons * 200;
  32.                     tonsMicrobus += tons;
  33.                 }
  34.                 else if (tons >= 4 && tons <= 11)
  35.                 {
  36.                     truck = tons * 175;
  37.                     tonsTruck += tons;
  38.                 }
  39.                 else
  40.                 {
  41.                     train = tons * 120;
  42.                     tonsTrain += tons;
  43.                 }
  44.             }
  45.             sumTons = tonsTrain + tonsMicrobus + tonsTruck;
  46.             avarageTons = (microbus + truck + train) / sumTons;
  47.  
  48.             double microbusPerCent = (tonsMicrobus / sumTons) * 100;
  49.             double truckPerCent = (tonsTruck / sumTons) * 100;
  50.             double trainPerCent = (tonsTrain / sumTons) * 100;
  51.  
  52.             Console.WriteLine($"{avarageTons:f2}");
  53.             Console.WriteLine($"{microbusPerCent:f2}%");
  54.             Console.WriteLine($"{truckPerCent:f2}%");
  55.             Console.WriteLine($"{trainPerCent:f2}%");
  56.  
  57.         }
  58.     }
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement