drunin89

SoftUni Camp

Nov 24th, 2016
168
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.60 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 SoftUniCamp
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             int groups = int.Parse(Console.ReadLine());
  14.             int totalPeople = 0;
  15.             double car = 0;
  16.             double bus = 0;
  17.             double smallBus = 0;
  18.             double bigBus = 0;
  19.             double train = 0;
  20.             for (int i = 1; i <= groups; i++)
  21.             {
  22.                 int people = int.Parse(Console.ReadLine());
  23.                 totalPeople += people;
  24.                 if (people>0 && people<=5)
  25.                 {
  26.                     car += people;
  27.                 }
  28.                 else if (people>=6 && people <=12)
  29.                 {
  30.                     bus += people;
  31.                 }
  32.                 else if (people>=13 && people <=25)
  33.                 {
  34.                     smallBus += people;
  35.                 }
  36.                 else if (people>=26 && people<=40 )
  37.                 {
  38.                     bigBus += people;
  39.                 }
  40.                 else if (people >=41)
  41.                 {
  42.                     train += people;
  43.                 }
  44.             }
  45.             Console.WriteLine("{0:F2}%", car/totalPeople*100);
  46.             Console.WriteLine("{0:F2}%", bus / totalPeople * 100);
  47.             Console.WriteLine("{0:F2}%", smallBus / totalPeople * 100);
  48.             Console.WriteLine("{0:F2}%", bigBus / totalPeople * 100);
  49.             Console.WriteLine("{0:F2}%", train / totalPeople * 100);
  50.         }
  51.     }
  52. }
Add Comment
Please, Sign In to add comment