Arrange the following lines to make a program that determines when the number of people in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 InputMismatch Exception 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. Mouse: Drag/drop Keyboard: Grab/release Spacebar (or Enter). Move D000. Cancel (Esc Unused catch { scnr.nextLine(); Check You've added 11 blocks, but 10 were expected. Not all tests passed. MaxOccupancy Tracker.java while (totalNumPeople < maxNumPeople) { try { totalNumPeople += scnr.nextInt (); if (totalNumPeople < 0) { totalNumPeople = 0; } System.out.println("Occupancy: " + totalNumPeople); } catch (InputMismatch Exception e) { scnr.next(); System.out.println("Error"); } Load default template... } 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 InputMismatch Exception 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. Mouse: Drag/drop Keyboard: Grab/release Spacebar (or Enter). Move 0000. Cancel (Esc Unused System.out.println("Occupancy: " + totalNumPeople); } } catch (InputMismatchException e) { try { catch { while (totalNumPeople < maxNumPeople) { if (totalNumPeople < 0) { totalNumPeople = 0; } } System.out.println("Error"); scnr.next(); MaxOccupancy Tracker.java Load default template.... import java.util.Scanner; import java.util. InputMismatchException; public class MaxOccupancy Tracker { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int maxNumPeople = 10; int totalNumPeople = 0; System.out.println("We're full!"); 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 InputMismatch Exception 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. Mouse: Drag/drop Keyboard: Grab/release Spacebar (or Enter). Move D000. Cancel (Esc Unused catch { scnr.nextLine(); Check You've added 11 blocks, but 10 were expected. Not all tests passed. MaxOccupancy Tracker.java while (totalNumPeople < maxNumPeople) { try { totalNumPeople += scnr.nextInt (); if (totalNumPeople < 0) { totalNumPeople = 0; } System.out.println("Occupancy: " + totalNumPeople); } catch (InputMismatch Exception e) { scnr.next(); System.out.println("Error"); } Load default template... } 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 InputMismatch Exception 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. Mouse: Drag/drop Keyboard: Grab/release Spacebar (or Enter). Move 0000. Cancel (Esc Unused System.out.println("Occupancy: " + totalNumPeople); } } catch (InputMismatchException e) { try { catch { while (totalNumPeople < maxNumPeople) { if (totalNumPeople < 0) { totalNumPeople = 0; } } System.out.println("Error"); scnr.next(); MaxOccupancy Tracker.java Load default template.... import java.util.Scanner; import java.util. InputMismatchException; public class MaxOccupancy Tracker { public static void main (String[] args) { Scanner scnr = new Scanner(System.in); int maxNumPeople = 10; int totalNumPeople = 0; System.out.println("We're full!");
Expert Answer:
Related Book For
College Algebra Graphs and Models
ISBN: 978-0321845405
5th edition
Authors: Marvin L. Bittinger, Judith A. Beecher, David J. Ellenbogen, Judith A. Penna
Posted Date:
Students also viewed these programming questions
-
Alpha Corp. (a spinoff of Alpha Beta) makes Product X, which is composed of two Part Ys. Complete the following MRP matrices for X and Y, and construct a planned order report. When are orders placed...
-
Nutone, Inc., owns Othello Corp. The two companies' individual balance sheets follow: Requirements 1. Prepare a consolidated balance sheet of Nutone, Inc. It is sufficient to complete the...
-
The assessment consists of ONE (1) question.Answer ALL sub-sections to meet ALL the learning outcomes. This assessment is graded out of 15 and counts for 15 per cent of the marks for this unit. This...
-
Why is it necessary to serve nonparty witnesses with a subpoena to appear at trial?
-
In December 2012, Pavelka Companys manager estimated next years total direct labor cost assuming 50 persons working an average of 2,000 hours each at an average wage rate of $ 15 per hour. The...
-
ABC, DEF, and XYZ are stocks that are in the same industry and very similar in nearly every way except their P/E ratio. ABC has a P/E of 5, DEF has a P/E of 10, and XYZ has a P/E of 100. Based on...
-
Part I of this case, presented in Chapter 3, discussed the situation of D'Leon Inc., a regional snack foods producer, after an expansion program. D'Leon had increased plant capacity and undertaken a...
-
Construct a frequency distribution and has the greatest relative frequency and which has the least relative frequency? relative frequency histogram for the data set using five classes. Which class...
-
At the beginning of 2021 Lemon Company has a share price of $3.00, and a beta of 2, whereas Lime Company shares have a beta of 1.5 and a share price of $4.80. If the risk-free interest rate is 4% and...
-
As of June 3 0 th , H Co . has assets of 1 0 0 , 0 0 0 $ and owners ewuity if 5 , 0 0 0 $ . What are the liabilities for H Co . as of June 3 0 th ?
-
3. (20pts): What is the time complexity of the functions below? Time complexity Code a) def test(n): for i in range(n): for j in range(n): print(i, j) b) def test(n): for i in range(n): print(i) for...
-
Sheffield Corp. manufactures and sells high-priced motorcycles. The Engine Division produces and sells engines to other motorcycle companies and internally to its Retail Division. It has been decided...
-
What are the key indicators of successful organizational change implementation, and how can organizations measure and evaluate their progress toward desired outcomes effectively ?
-
A. Pick a product that might be packaged in the shape of arectangular prism. The surface area of a rectangular prism can befound with the formula: SA=2lw + 2wh + 2lh. The volume of arectangular prism...
-
Suppose you won a financial literacy competition and are given FJS10000 to invest, with the condition that investment can be done either in, i) Invest in Unit trust of Fiji or Invest in Fijian...
-
Using the intermediate value theorem, determine, if possible, whether the function f has a zero between a and b. a. f(x) = 4x2 - 5x - 3; a = 1, b = 2 b. f(x) = x3 - 4x2 + x + 2; a = - 1, b = 1
-
Decompose into partial fractions. a. 5 / (x + 2)2 (x + 1) b. (-8x + 23) / (2x2 + 5x - 12)
-
Find the inverse of the one-to-one function f (x) = 1/(x - 4). Give the domain and the range of f and of f -1 and then graph both f and f -1 on the same set of axes.
-
You have just been telephoned by the chief accountant of a listed company client, Randerston plc, to tell you that there has been a computer breakdown and that some parts of the data concerning...
-
Consider the following situations: (a) Assume that you are a partner in a two partner practice with total practice income of 250 000. One of your clients (a private limited company with a turnover of...
-
You have been asked by your audit partner to be senior in charge of the audit of a small public limited company. Unbeknown to the partner, you hold 1000 of the 100 000 shares in the company. Do you...
Study smarter with the SolutionInn App