Advertisement
Niicksana

SoftUni Camp

Dec 11th, 2017
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.08 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 _4.SoftUni_Camp
  8. {
  9.     class Program
  10.     {
  11.         static void Main(string[] args)
  12.         {
  13.             // Exam - 20 November 2016 - Morning
  14.             int groups = int.Parse(Console.ReadLine());
  15.  
  16.             int car = 0;
  17.             int minibus = 0;
  18.             int smallBus = 0;
  19.             int bigBus = 0;
  20.             int train = 0;
  21.  
  22.             double totalPeople = 0;
  23.             for (int row = 1; row <= groups; row++)
  24.             {
  25.                 int people = int.Parse(Console.ReadLine());
  26.  
  27.                 if (people <= 5)
  28.                 {
  29.                     totalPeople += people;
  30.                     car += people;
  31.                 }
  32.  
  33.                 else if (people >= 6 && people <= 12)
  34.                 {
  35.                     totalPeople += people;
  36.                     minibus += people;
  37.                 }
  38.  
  39.                 else if (people >= 13 && people <= 25)
  40.                 {
  41.                     totalPeople += people;
  42.                     smallBus += people;
  43.                 }
  44.  
  45.                 else if (people >= 26 && people <= 40)
  46.                 {
  47.                     totalPeople += people;
  48.                     bigBus += people;
  49.                 }
  50.  
  51.                 else
  52.                 {
  53.                     totalPeople += people;
  54.                     train += people;
  55.                 }
  56.             }
  57.  
  58.             double carGroup = (car * 100) / totalPeople;
  59.             double minibusGroup = (minibus * 100) / totalPeople;
  60.             double smallBusgroup = (smallBus * 100) / totalPeople;
  61.             double bigBusGroup = (bigBus * 100) / totalPeople;
  62.             double trainGroup = (train * 100) / totalPeople;
  63.  
  64.             Console.WriteLine("{0:f2}%", carGroup);
  65.             Console.WriteLine("{0:f2}%", minibusGroup);
  66.             Console.WriteLine("{0:f2}%", smallBusgroup);
  67.             Console.WriteLine("{0:f2}%", bigBusGroup);
  68.             Console.WriteLine("{0:f2}%", trainGroup);
  69.         }          
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement