Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Missy is keeping track of people coming to her party this weekend. She has her l

ID: 440874 • Letter: M

Question

Missy is keeping track of people coming to her party this weekend. She has her list of people who are allowed entry. She wants you to write a program for the bouncer to use to determine whether the person is allowed entry or not. She has decided on this list of people who are allowed to enter: Chloe, Angela, Bart, Francis, Elizabeth, George, Harrison, and Huey. An example run follows: Who is seeking entry to the party? Harrison Allow Harrison to enter! Another example run follows: Who is seeking entry to the party? Chris Turn Chris away, not on the list. Goal: The task is to write a program named PartyBounce that creates an array (in the main method) of the accepted names for the party, prompts the user for a name (in main), calls a method (isNameOnList) to search and determine whether that name is on the list, and prints a message to the bouncer.

Explanation / Answer

import java.util.Scanner; public class PartyBouncer { public static void main(String[] args) { String[] list=new String[]{"Chloe", "Angela", "Bart", "Francis", "Elizabeth", "George", "Harrison","Huey"}; Scanner input=new Scanner(System.in); String person; while(true){//infinite loop System.out.print("Who is seeking entry to the party?"); person=input.next(); if(isNameOnList(list,person)) System.out.println("Allow "+person+" to enter!"); else System.out.println("Turn "+person+" away, not on the list."); } //input.close(); } public static boolean isNameOnList(String list[],String target){ for(int i=0;i