Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I NEED THE FULL CODE WRITTEN IN JAVA!!!!!!!!!!! ( i added more instructions in the written description ) In this program, you will be keeping

I NEED THE FULL CODE WRITTEN IN JAVA!!!!!!!!!!! (i added more instructions in the written description)
In this program, you will be keeping track of how many people enter and exit a room with a posted capacity over a certain period of time. You will start with there being no people in this room. You will have an unspecified number of lines of input given to you that represent how the room capacity changes as time goes on.
Your input will start with a single integer on each of the first two lines of input. The integer on the first line is the room capacity. The integer on the second line is the amount of time you will be watching people enter and exit the room. The lines following this will be individual instances of how the room capacity changes over time. Each of these lines of input read represents 1 unit of time passing. The number of lines of input for the change in capacity may be a larger number than the amount of time you are told to track changes. You will only continue reading lines for as long as you are asked and the lines after that will be inconsequential.
There are three different possibilities for the lines representing a change in capacity. If there is a positive number of people entering or leaving the room, there will be a certain number of the character I representing how many people either entered or left, and at the end of the line of input there will be either an E for entering or an for leaving. If there is no change in the room capacity at this unit of time, the line will just have a 0 on it.
An example of this input format is:
15
12
IIIIE
IIIE
IIL
IIIE
0
IIIE
IIIIIL
IIIL
0
IIIE
IIIL
IIIL
What this example means with line by line annotations is:
//15 is the room capacity
//12 is the amount of time you will watch
IIIIE //4 people enter
IIIE //3 people enter
IIL //2 people leave
IIIE //3 people enter
0// no change in capacity
IIIE //3 people enter
If while reading the input the number of occupants in the room ever exceeds the capacity you will print the output Capacity Exceeded wifh a newline following, print how far over the capcaity the number went with a newline following, and then exit the program.
If whule reading the input the number of occupants in the room ever crosses into a negative number, you will print the output Impossible with the newline following, print how far under zero you went (as a postive number) with a newline following, and then exit the program.
Once you have finished watching the entering and leaving of poeple into the room for the specified amount of time, you will check if anyone remains in the room.
If you finish watching and there is no one left in the room, give the output Empty Room. If there is anyone left in the room, print how many are left in the format X People In The Room.
HINTS
System.exit(0); immediately exits the program
SAMPLE CASE
input:
15
7
IIIE
IIIE
IIIIIE
IIIL
IIIL
IIL
IIE
IIIE
IIIIL
OUTPUT:4 People In The Room
Input:
5
5
IIIIIE
IIL
IIL
IL
IIE
OUTPUT:2 People In The Room
image text in transcribed

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

Object Databases The Essentials

Authors: Mary E. S. Loomis

1st Edition

020156341X, 978-0201563412

Students also viewed these Databases questions

Question

Evaluate three pros and three cons of e-prescribing

Answered: 1 week ago

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago