simonradev

SoftUniCamp

Mar 11th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.90 KB | None | 0 0
  1. namespace SoftUniCamp
  2. {
  3.     using System;
  4.  
  5.     class SoftUniCamp
  6.     {
  7.         static void Main()
  8.         {
  9.             int numberOfInputs = int.Parse(Console.ReadLine());
  10.  
  11.             int peopleTravellingByCar = 0;
  12.             int peopleTravellingByVerySmallBus = 0;
  13.             int peopleTravellingBySmallBus = 0;
  14.             int peopleTraveliingByBus = 0;
  15.             int peopleTravellingByTrain = 0;
  16.             double totalTravellers = 0;
  17.  
  18.             for (int currInput = 0; currInput < numberOfInputs; currInput++)
  19.             {
  20.                 int groupSize = int.Parse(Console.ReadLine());
  21.  
  22.                 totalTravellers += groupSize;
  23.  
  24.                 if (groupSize <= 5)
  25.                 {
  26.                     peopleTravellingByCar += groupSize;
  27.                 }
  28.                 else if (groupSize >= 6 && groupSize <= 12)
  29.                 {
  30.                     peopleTravellingByVerySmallBus += groupSize;
  31.                 }
  32.                 else if (groupSize >= 13 && groupSize <= 25)
  33.                 {
  34.                     peopleTravellingBySmallBus += groupSize;
  35.                 }
  36.                 else if (groupSize >= 26 && groupSize <= 40)
  37.                 {
  38.                     peopleTraveliingByBus += groupSize;
  39.                 }
  40.                 else if (groupSize >= 41)
  41.                 {
  42.                     peopleTravellingByTrain += groupSize;
  43.                 }
  44.             }
  45.  
  46.             Console.WriteLine($"{((peopleTravellingByCar / totalTravellers) * 100.0):f2}%");
  47.             Console.WriteLine($"{((peopleTravellingByVerySmallBus / totalTravellers) * 100.0):f2}%");
  48.             Console.WriteLine($"{((peopleTravellingBySmallBus / totalTravellers) * 100.0):f2}%");
  49.             Console.WriteLine($"{((peopleTraveliingByBus / totalTravellers) * 100.0):f2}%");
  50.             Console.WriteLine($"{((peopleTravellingByTrain / totalTravellers) * 100.0):f2}%");
  51.         }
  52.     }
  53. }
Add Comment
Please, Sign In to add comment