Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Must be in JAVA. Halifax is finally opening a cat cafe (Catpuccino) and theyre anticipating a lot of visitors on the first day. To avoid

Must be in JAVA.

Halifax is finally opening a cat cafe (Catpuccino) and theyre anticipating a lot of visitors on the first day. To avoid overwhelming the cats, theres a limit to how many people the owners want to allow in at once. Once the cafe is at capacity (no more room), the store wont let anyone in until someone leaves.

Write a program that will track the number of people that enter the cafe and dont let people in if there is no room. Use a Scanner to read in a sequence of integers. The first integer indicates the total capacity of the cafe. Then you will read in a sequence of 1 and 0 (1 means someone wants to enter the cafe and 0 means someone leaves). If someone wants to enter the cafe but it is full, then ignore the request and read the next integer. When -1 is entered, that means that the cafe is closed. When the cafe closes, print out how many people entered the cafe in total.

Details

Input

An integer representing the maximum capacity, followed by a sequence of 1s and 0s, until a -1 is read.

Output

The total number of customers.

Sample input:10 1 1 1 1 0 1 1 1 0 1 1 1 1 1 1 1 0 1 -1 Sample output:Total Customers: 13

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Programming questions

Question

What role does contribution margin play in this equation?

Answered: 1 week ago

Question

The process can be applied for more than two Brownian motions.

Answered: 1 week ago