Rosen_Tenev

Untitled

Feb 1st, 2019
203
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.21 KB | None | 0 0
  1. using System;
  2.  
  3. namespace _03.Elevator
  4. {
  5.     class Elevator
  6.     {
  7.         static void Main(string[] args)
  8.         {
  9.             int numPeople = int.Parse(Console.ReadLine());
  10.             int capacity = int.Parse(Console.ReadLine());
  11.             int temp = numPeople;
  12.             int cources = 0;
  13.             if (numPeople < capacity)
  14.             {
  15.                 Console.WriteLine("All the persons fit inside in the elevator.");
  16.                 Console.WriteLine("Only one course is needed.");
  17.             }
  18.             else if (numPeople % capacity == 0)
  19.             {
  20.                 while (numPeople >= capacity)
  21.                 {
  22.                     numPeople -= capacity;
  23.                     cources++;
  24.                 }
  25.                 Console.WriteLine($"{cources} courses * {capacity} people");
  26.             }
  27.             else
  28.             {
  29.                 while (numPeople > capacity)
  30.                 {
  31.                     numPeople -= capacity;
  32.                     cources++;
  33.                 }
  34.                 Console.WriteLine($"{cources} cources * {capacity} people");
  35.                 Console.WriteLine($"+ 1 cources * {temp-(cources * capacity)} people");
  36.             }
  37.         }
  38.     }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment