Question: Write a java program. You need to control the number of people who can be in a bar at the same time. Groups of people

Write a java program. You need to control the number of people who can be in a bar at the same time. Groups of people can always leave the bar, but a group cannot enter the bar if they would make the number of people in the bar exceed the maximum of 100 occupants. Write a program that reads the sizes of the groups that arrive or depart. Use negative numbers for departures. After each input, display the current number of occupants. As soon as the bar holds the maximum number of people, report that the bar is full and exit the program.

The output should be like this:

People entering or leaving: 5

People in bar: 5

People entering or leaving: 10

People in bar: 15

People entering or leaving: - 5

People in bar: 10

People entering or leaving: 90

People in bar: 100

Bar is full

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!