Answered step by step
Verified Expert Solution
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 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 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 on it
An example of this input format is:
IIIIE
IIIE
IIL
IIIE
IIIE
IIIIIL
IIIL
IIIE
IIIL
IIIL
What this example means with line by line annotations is:
is the room capacity
is the amount of time you will watch
IIIIE people enter
IIIE people enter
IIL people leave
IIIE people enter
no change in capacity
IIIE 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; immediately exits the program
SAMPLE CASE
input:
IIIE
IIIE
IIIIIE
IIIL
IIIL
IIL
IIE
IIIE
IIIIL
OUTPUT: People In The Room
Input:
IIIIIE
IIL
IIL
IL
IIE
OUTPUT: People In The Room
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started