Arrange the following lines to make a program that determines when the number occupants. The program continually gets the number of people entering or leavin entered, and -3 means three people left. After each input, the program outputs th number of people in the restaurant equals or exceeds 10, the program exits.
Operations
In mathematics and computer science, an operation is an event that is carried out to satisfy a given task. Basic operations of a computer system are input, processing, output, storage, and control.
Basic Operators
An operator is a symbol that indicates an operation to be performed. We are familiar with operators in mathematics; operators used in computer programming are—in many ways—similar to mathematical operators.
Division Operator
We all learnt about division—and the division operator—in school. You probably know of both these symbols as representing division:
Modulus Operator
Modulus can be represented either as (mod or modulo) in computing operation. Modulus comes under arithmetic operations. Any number or variable which produces absolute value is modulus functionality. Magnitude of any function is totally changed by modulo operator as it changes even negative value to positive.
Operators
In the realm of programming, operators refer to the symbols that perform some function. They are tasked with instructing the compiler on the type of action that needs to be performed on the values passed as operands. Operators can be used in mathematical formulas and equations. In programming languages like Python, C, and Java, a variety of operators are defined.
![PARTICIPATION
ACTIVITY
Arrange the following lines to make a program that determines when the number of people in a restaurant equals or exceeds 10
occupants. The program continually gets the number of people entering or leaving the restaurant. Ex: 2 means two people
entered, and -3 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 10, the program exits.
If an Input MismatchException exception occurs, the program should get and discard a single string from input. Ex: The input "2
abc 8" should result in 10 occupants. Not all lines are used in the solution.
How to use this tool ✓
Unused
totalNumPeople += scnr.nextInt ();
while (totalNumPeople < maxNumPeople) {
}
}
11.1.5: Handling input exceptions: restaurant max occupancy tracker.
catch {
try {
catch (InputMismatchException e) {
scnr .nextLine();
scnr.next();
System.out.println("Error");
}
System.out.println("Occupancy:
Check
11
+ totalNumPeople);
MaxOccupancy Tracker.java
import java.util.Scanner;
import java.util.InputMismatchException;
Load default template...
public class MaxOccupancyTracker {
public static void main(String [] args) {
Scanner scnr = new Scanner(System.in);
int maxNumPeople 10;
int totalNumPeople = 0;
}
=
System.out.println("We're full!");](/v2/_next/image?url=https%3A%2F%2Fcontent.bartleby.com%2Fqna-images%2Fquestion%2F1f508c53-af29-498e-8791-77e45ebbdaaf%2Fdcd57340-d6cd-4414-9b94-de3f348aa2d6%2Fte3h43_processed.png&w=3840&q=75)

Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images









