Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Arrange the following lines to make a program that determines when the number of people in a restaurant equals or exceeds 1 0 occupants. The
Arrange the following lines to make a program that determines when the number of people in a restaurant equals or exceeds occupants. The program continually gets the number of people entering or leaving the restaurant. Ex: means two people entered, and means three people left. After each input, the program outputs the number of people in the restaurant. Once the number of people in the restaurant equals or exceeds the program exits.
If an InputMismatchException exception occurs, the program should get and discard a single string from input. Ex The input abc should result in occupants. Not all lines are used in the solution.
How to use this tool
Unused
catch
try
catch InputMismatchException e
senr next ;
scnr nextline;
System.out.printlnError;
totalNumPeople scnr nextInt ;
while totalNumPeople maxNumPeople
System.out.printlnOccupancy: totalNumPeople;
MaxOccupancyTracker.java
Load default template...
import java.util.scanner;
import java.util. InputMismatchException;
public class MaxOccupancyTracker
public static void mainString args f
Scanner scnr new Scanner
System.in;
int maxNumPeople ;
int totalNumPeople ;
System.out.printlnWere full!";
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