NMDanny

Untitled

May 1st, 2014
231
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.49 KB | None | 0 0
  1.         public static int BlockedVehicles(int size)
  2.         {
  3.             int entered = 0;
  4.             int weight = 0;
  5.             int height = 0;
  6.             int blocked = 0;
  7.             while (entered < size)
  8.             {
  9.                 while (weight <= 0)
  10.                 {
  11.                     Console.WriteLine("Type the vehicle's weight, it must be over 0.");
  12.                     weight = int.Parse(Console.ReadLine());
  13.                 }
  14.                 while (height <= 0)
  15.                 {
  16.                     Console.WriteLine("Type the vehicle's height, itm ust be over 0.");
  17.                     height = int.Parse(Console.ReadLine());
  18.                 }
  19.                 if (weight < 10 && height < 5)
  20.                 {
  21.                     Console.WriteLine("You can pass.");
  22.                     entered++;
  23.                 }
  24.                 else
  25.                 {
  26.                     Console.WriteLine("You can't pass.");
  27.                     blocked++;
  28.                 }
  29.                 weight = 0;
  30.                 height = 0;
  31.             }
  32.             return blocked;
  33.         }
  34.         static void Main(string[] args)
  35.         {
  36.             int size = 0;
  37.             while (size <= 0)
  38.             {
  39.                 Console.WriteLine("Type how many parking spaces area available, it must be over 0.");
  40.                 size = int.Parse(Console.ReadLine());
  41.             }
  42.             Console.WriteLine("{0} vehicles could not enter the garage.", BlockedVehicles(size));
  43.  
  44.         }
Advertisement
Add Comment
Please, Sign In to add comment