Advertisement
simonradev

SoftUniCamp

May 28th, 2017
83
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.04 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 SoftUniCamp
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int numberOfInputs = int.Parse(Console.ReadLine());
  14.  
  15.             int totalCountOfPeople = 0;
  16.  
  17.             double byCar = 0;
  18.             double byBus = 0;
  19.             double bySmallBus = 0;
  20.             double byBigBus = 0;
  21.             double byTrain = 0;
  22.  
  23.             for (int currInput = 0; currInput < numberOfInputs; currInput++)
  24.             {
  25.                 int sizeOfGroup = int.Parse(Console.ReadLine());
  26.  
  27.                 totalCountOfPeople += sizeOfGroup;
  28.  
  29.                 if (sizeOfGroup <= 5)
  30.                 {
  31.                     byCar += sizeOfGroup;
  32.                 }
  33.                 else if (sizeOfGroup >= 6 && sizeOfGroup <= 12)
  34.                 {
  35.                     byBus += sizeOfGroup;
  36.                 }
  37.                 else if (sizeOfGroup >= 13 && sizeOfGroup <= 25)
  38.                 {
  39.                     bySmallBus += sizeOfGroup;
  40.                 }
  41.                 else if (sizeOfGroup >= 26 && sizeOfGroup <= 40)
  42.                 {
  43.                     byBigBus += sizeOfGroup;
  44.                 }
  45.                 else
  46.                 {
  47.                     byTrain += sizeOfGroup;
  48.                 }
  49.             }
  50.  
  51.             double percentByCar = (byCar / totalCountOfPeople) * 100;
  52.             double percentByBus = (byBus / totalCountOfPeople) * 100;
  53.             double percentBySmallBus = (bySmallBus / totalCountOfPeople) * 100;
  54.             double percentByBigBus = (byBigBus / totalCountOfPeople) * 100;
  55.             double percentByTrain = (byTrain / totalCountOfPeople) * 100;
  56.  
  57.             Console.WriteLine($"{percentByCar:f2}%");
  58.             Console.WriteLine($"{percentByBus:f2}%");
  59.             Console.WriteLine($"{percentBySmallBus:f2}%");
  60.             Console.WriteLine($"{percentByBigBus:f2}%");
  61.             Console.WriteLine($"{percentByTrain:f2}%");
  62.         }
  63.     }
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement