In: Computer Science
PYTHON
Solution:
#To hold total occupants count
total_occupants = 0
#Will get executed till the total ocuupants reach 100
while(total_occupants < 100):
#Getting group size entering or leaving
group_size = input("Enter the size of group arrive / depart :
")
#converting string to integer
group_size = int(group_size)
#adding the group size to the count of total occupants
total_occupants += group_size
#checking whether the total occupants count reached
maximum
if(total_occupants >= 100):
#printing bar is full and exiting from loop
print("Bar is full.")
break;
#displaying total occupants currently there in bar
print("Total number of occupants at this time : ",
total_occupants)
Program screenshot:
Output screenshot: