Advertisement
DeeAG

03.Logistics

Oct 31st, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.65 KB | None | 0 0
  1. namespace _03.Logistics
  2. {
  3. using System;
  4.     class StartUp
  5.     {
  6.         static void Main(string[] args)
  7.         {
  8.             double doubleConverter = 1.0;
  9.             int n = int.Parse(Console.ReadLine());
  10.  
  11.             double priceMiniBus = 0;
  12.             double priceTruck = 0;
  13.             double priceTrain = 0;
  14.             int allTones = 0;
  15.             int tonesMinibus = 0;
  16.             int tonesTruck = 0;
  17.             int tonesTrain = 0;
  18.             for (int i = 0; i < n; i++)
  19.             {
  20.                 int tones = int.Parse(Console.ReadLine());
  21.                 allTones += tones;
  22.                 if (tones < 4)
  23.                 {
  24.                     tonesMinibus += tones;
  25.                     priceMiniBus += tones * 200;
  26.                 }
  27.                 else if (tones < 12)
  28.                 {
  29.                     tonesTruck += tones;
  30.                     priceTruck += tones * 175;
  31.                 }
  32.                 else
  33.                 {
  34.                     tonesTrain += tones;
  35.                     priceTrain += tones * 120;
  36.                 }
  37.             }
  38.             double middlePrice = (priceMiniBus + priceTruck + priceTrain) / allTones;
  39.             double pTonesMinibus = doubleConverter * tonesMinibus / allTones * 100;
  40.             double pTonesTruck = doubleConverter * tonesTruck / allTones * 100;
  41.             double pTonesTrain = doubleConverter * tonesTrain / allTones * 100;
  42.             Console.WriteLine($"{middlePrice:f2}");
  43.             Console.WriteLine($"{pTonesMinibus:f2}%");
  44.             Console.WriteLine($"{pTonesTruck:f2}%");
  45.             Console.WriteLine($"{pTonesTrain:f2}%");
  46.            
  47.         }
  48.     }
  49. }
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement