pavlinpetkov88

SoftUniCamps

Nov 28th, 2016
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.61 KB | None | 0 0
  1. using System;
  2.  
  3. class SoftUniCamp
  4. {
  5.     static void Main()
  6.     {
  7.  
  8.         int countOfGroup = int.Parse(Console.ReadLine());
  9.  
  10.         int totalSumOfGroup = 0;
  11.  
  12.         double groupWithCar = 0.00;
  13.         double groupWithMircobus = 0.00;
  14.         double groupWithSmallBus = 0.00;
  15.         double groupWithBus = 0.00;
  16.         double groupWithTrain = 0.00;
  17.  
  18.  
  19.  
  20.         for (int i = 0; i < countOfGroup; i++)
  21.         {
  22.             int numberOfGroup = int.Parse(Console.ReadLine());
  23.  
  24.             totalSumOfGroup += numberOfGroup;
  25.  
  26.             if (numberOfGroup <= 5) groupWithCar += numberOfGroup;
  27.             else if (numberOfGroup <= 12) groupWithMircobus += numberOfGroup;
  28.             else if (numberOfGroup <= 25) groupWithSmallBus += numberOfGroup;
  29.             else if (numberOfGroup <= 40) groupWithBus += numberOfGroup;
  30.             else
  31.             {
  32.                 groupWithTrain += numberOfGroup;
  33.             }
  34.         }
  35.  
  36.         double percentWithCar = groupWithCar * 100 /  totalSumOfGroup;
  37.         double percentWithMicrobus = groupWithMircobus * 100 / totalSumOfGroup;
  38.         double percentWithSmallBus = groupWithSmallBus / totalSumOfGroup * 100;
  39.         double percentWithBus = groupWithBus / totalSumOfGroup * 100;
  40.         double percentWithTrain = groupWithTrain / totalSumOfGroup * 100;
  41.        
  42.         Console.WriteLine("{0:F2}%", percentWithCar);
  43.         Console.WriteLine("{0:F2}%", percentWithMicrobus);
  44.         Console.WriteLine("{0:F2}%", percentWithSmallBus);
  45.         Console.WriteLine("{0:F2}%", percentWithBus);
  46.         Console.WriteLine("{0:F2}%", percentWithTrain);
  47.  
  48.     }
  49. }
Add Comment
Please, Sign In to add comment