Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static int BlockedVehicles(int size)
- {
- int entered = 0;
- int weight = 0;
- int height = 0;
- int blocked = 0;
- while (entered < size)
- {
- while (weight <= 0)
- {
- Console.WriteLine("Type the vehicle's weight, it must be over 0.");
- weight = int.Parse(Console.ReadLine());
- }
- while (height <= 0)
- {
- Console.WriteLine("Type the vehicle's height, itm ust be over 0.");
- height = int.Parse(Console.ReadLine());
- }
- if (weight < 10 && height < 5)
- {
- Console.WriteLine("You can pass.");
- entered++;
- }
- else
- {
- Console.WriteLine("You can't pass.");
- blocked++;
- }
- weight = 0;
- height = 0;
- }
- return blocked;
- }
- static void Main(string[] args)
- {
- int size = 0;
- while (size <= 0)
- {
- Console.WriteLine("Type how many parking spaces area available, it must be over 0.");
- size = int.Parse(Console.ReadLine());
- }
- Console.WriteLine("{0} vehicles could not enter the garage.", BlockedVehicles(size));
- }
Advertisement
Add Comment
Please, Sign In to add comment