Pazzobg

Programming Basics Exams/20NOV16_Evening/04. SoftUniCamp

Mar 11th, 2017
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.26 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _07.SoftUniCamp
  4. {
  5.     class SoftUniCamp
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int groups = int.Parse(Console.ReadLine());
  10.             double peopleTotal = 0.0;
  11.             int carCounter = 0;
  12.             int minibusCounter = 0;
  13.             int smallBusCounter = 0;
  14.             int busCounter = 0;
  15.             int trainCounter = 0;
  16.  
  17.             for (int i = 0; i < groups; i++)
  18.             {
  19.                 int input = int.Parse(Console.ReadLine());
  20.                 peopleTotal += input;
  21.                 if (input <= 5) carCounter += input;
  22.                 else if (input <= 12) minibusCounter += input;
  23.                 else if (input <= 25) smallBusCounter += input;
  24.                 else if (input <= 40) busCounter += input;
  25.                 else trainCounter += input;
  26.             }
  27.             Console.WriteLine("{0:f2}%", ((carCounter / peopleTotal) * 100));
  28.             Console.WriteLine("{0:f2}%", ((minibusCounter / peopleTotal) * 100));
  29.             Console.WriteLine("{0:f2}%", ((smallBusCounter / peopleTotal) * 100));
  30.             Console.WriteLine("{0:f2}%", ((busCounter / peopleTotal) * 100));
  31.             Console.WriteLine("{0:f2}%", ((trainCounter / peopleTotal) * 100));
  32.         }
  33.     }
  34. }
Advertisement
Add Comment
Please, Sign In to add comment