Create a class named Pizza with a String array data field that can hold the names of up to 10 pizza toppings. Also include a field for the price. Include a constructor that takes two parameters: the array of toppings and the number of toppings stored in the list. The constructor creates a String description from the list of toppings, adding a comma between each topping. It also sets the price at $14 plus $2 for each topping. Include a toString() method to display the Pizza description and price. Save the file as Pizza.java. b. Create a subclass named DeliveryPizza that inherits from Pizza but adds a numeric delivery fee and a String delivery address. The constructor’s parameters include the array of toppings, the delivery address, and the number of toppings. The delivery fee is $3 if the Pizza ordered costs more than $18; otherwise, the delivery fee is $5. Save the file as DeliveryPizza.java. c. Write an application that prompts the user for topping values for a Pizza. Allow the user to continually enter toppings until entering a QUIT constant or reaching 10 toppings. Also ask the user whether the Pizza is to be delivered. If the Pizza is to be delivered, prompt the user for the delivery address and construct a DeliveryPizza object; otherwise, construct a Pizza object. Then, display all the values for the Pizza. Save the file as DemoPizza.java.
> Explain how the value of p, the probability of success, affects the shape of the distribution of a binomial random variable.
> Explain how the value of n, the number of trials in a binomial experiment, affects the shape of the distribution of a binomial random variable.
> Explain what “success” means in a binomial probability experiment.
> One measure of successful investing is being able to “beat the market.” To beat the market in any given year, an investor must earn a rate of return greater than the rate of return of some market basket of stocks, such as the Dow Jones Industrial Average
> Toxic Epidermal Necrolysis (TEN), also known as Lyell’s syndrome, is a life- threatening disease characterized by blisters that cover the skin and extensive peeling off of skin. In a double-blind, randomized, placebo- controlled study of the effects of a
> The negative binomial probability distribution can be used to compute the probability of the random variable X, the number of trials necessary to observe r successes of a binomial experiment. The probability distribution function is given by Consider a r
> A probability distribution for the random variable X, the number of trials until a success is observed, is called the geometric probability distribution. It has the same criteria as the binomial distribution (see page 313), except that the number of tria
> When taking a systematic random sample of size n, every group of size n from the population has the same chance of being selected.
> According to the High School Athletics Participation Survey, approximately 55% of students enrolled in high schools participate in athletic programs. You are performing a study of high school students and would like at least 11 students in the study t
> Historically, the probability that a passenger will miss a flight is 0.0995. Source: Passenger-Based Predictive Modeling of Airline No-show Rates by Richard D. Lawrence, Se June Hong, and Jacques Cherrier. Airlines do not like flights with empty seats, b
> In an election for President of the United States, a pollster wishes to predict the winner of the popular vote. She will do this by taking a random sample of 1000 voters and ask each to disclose who he/she will vote for. Assume the election is a dichotom
> The following excerpt is from the Racial Profiling Data Collection Resource Center. In 2006, the New York City Police Department stopped a half- million pedestrians for suspected criminal involvement. Raw statistics for these encounters suggest large rac
> In May, 2000, the Gallup Organization reported that 11% of adult Americans had a great deal of trust and confidence in the federal government handling domestic issues. Suppose a survey of a random sample of 1100 adult Americans finds that 84 have a great
> In March 1995, The Harris Poll reported that 80% of parents spank their children. Suppose a recent poll of 1030 adult Americans with children finds that 781 indicated that they spank their children. If we assume parents’ attitude toward spanking has not
> Clarinex-D is a medication whose purpose is to reduce the symptoms associated with a variety of allergies. In clinical trials of Clarinex-D, 5% of the patients in the study experienced insomnia as a side effect. (a) If 240 users of Clarinex-D are randoml
> In the Healthy Handwashing Survey conducted by Bradley Corporation, it was found that 64% of adult Americans operate the flusher of toilets in public restrooms with their foot. (a) If 500 adult Americans are randomly selected, how many would we expect t
> In a recent poll, the Gallup Organization found that 45% of adult Americans believe that the overall state of moral values in the United States is poor. (a) Compute the mean and standard deviation of the random variable X, the number of adults who believ
> According to flightstats.com, American Airlines flights from Dallas to Chicago are on time 80% of the time. Suppose 100 flights are randomly selected. (a) Compute the mean and standard deviation of the random variable X, the number of on-time flights in
> A(n)_____sample is obtained by dividing the population into homogeneous groups and randomly selecting individuals from each group.
> According to paint manufacturer DuPont, 6% of all cars worldwide are red. In the Sullivan Statistics Survey, of 175 respondents, 17, or 9.7%, indicated the color of their car is red. Determine if the results of the Sullivan Survey contradict those of DuP
> Twelve jurors are randomly selected from a population of 3 million residents. Of these 3 million residents, it is known that 45% are Hispanic. Of the 12 jurors selected, 2 are Hispanic. (a) What proportion of the jury described is Hispanic? (b) If 12 jur
> According to a study done by Nick Wilson of Otago University Wellington, the probability a randomly selected individual will cover his or her mouth with a tissue, handkerchief, or elbow (the method recommended by public health officials) when sneezing is
> According to a study done by Nick Wilson of Otago University Wellington, the probability a randomly selected individual will not cover his or her mouth when sneezing is 0.267. Suppose you sit on a bench in a mall and observe people’s habits as they sneez
> Clarinex-D is a medication whose purpose is to reduce the symptoms associated with a variety of allergies. In clinical trials of Clarinex-D, 5% of the patients in the study experienced insomnia as a side effect. A random sample of 20 Clarinex-D users is
> In the Healthy Handwashing Survey conducted by Bradley Corporation, it was found that 64% of adult Americans operate the flusher of toilets in public restrooms with their foot. Suppose a random sample of n = 20 adult Americans is obtained and the number
> In a recent poll, the Gallup Organization found that 45% of adult Americans believe that the overall state of moral values in the United States is poor. Suppose a survey of a random sample of 25 adult Americans is conducted in which they are asked to dis
> According to flightstats.com, American Airlines flights from Dallas to Chicago are on time 80% of the time. Suppose 15 flights are randomly selected, and the number of on-time flights is recorded. (a) Explain why this is a binomial experiment. (b) Determ
> n = 9, p = 0.8
> n = 10, p = 0.5
> What is random sampling? Why is it used and how does it compare with convenience sampling?
> Number of siblings
> Following the 2018 national midterm election, 18% of the governors of the 50 United States were female. Source: National Governors Association
> Create a file using any word-processing program or text editor. Write an application that prompts the user for the filename and displays the file’s path, name, folder, size, and time of last modification. Save the file as FileStatistics.java.
> Create an Exception class named GradeException that contains a static public array of valid grade letters (A, B, C, D, F, and I) that you can use to determine whether a grade is valid. Save the file as GradeException.java. b. Write an application that di
> Create a ScoreException class that extends Exception and whose constructor accepts a String parameter and passes it to the Exception class constructor. Save the file as ScoreException.java. b. Write an application in which you store at least five student
> Create a UsedCarException class that extends Exception; its constructor receives a value for a vehicle identification number (VIN) that is passed to the parent constructor so it can be used in a getMessage() call. Save the class as UsedCarException.java.
> Create a CourseException class that extends the Java Exception class and whose constructor receives a String that holds a college course’s department (for example, CIS), a course number (for example, 101), and a number of credits (for example, 3). Save t
> Write an application that prompts the user to enter an integer and displays its square root. Accept the user’s entry as a String using the nextLine() method. Then try to use the Integer.parseInt() method to convert the String to an integer. If the conver
> Write a program that prompts the user to enter an integer that represents an array size. Java generates a NumberFormatException if the user attempts to enter a noninteger value using nextInt(). Handle this exception by displaying an appropriate error mes
> Write a program that accepts a number of quarts from a user and converts the value to gallons. Include exception-handling capabilities in the program so that while any nonnumeric value is entered, the program continually displays an error message, reprom
> The Double.parseDouble() method requires a String argument, but it fails if the String cannot be converted to a floating-point number. Write an application in which you try accepting a double input from a user and catch a NumberFormatException if one is
> In a “You Do It” section of this chapter, you created a CalculatorDemo program that asked the user to solve an arithmetic problem and provided the Windows system calculator for assistance. Now modify that program to include the following improvements: ❯❯
> Throughout the Case Problems in this course, you have been using an Event class to store data about events for Yummy Catering. Now, create an application that prompts the user for details about eight Event objects, and create a data file that contains ea
> Serendipity Gifts accepts user orders for its products interactively. Users might make the following errors as they enter data: ❯❯ The item number ordered is not numeric, too low (less than 0), or too high (more than 9
> Create a DataEntryException class whose getMessage() method returns information about invalid integer data. Save the file as DataEntryException.java. b. Write a program named GetIDAndAge that continually prompts the user for an integer ID number and an
> Write an application named BadSubscriptCaught in which you declare an array of eight first names. Write a try block in which you prompt the user for an integer and display the name in the requested position. Create a catch block that catches the potentia
> The Talk-A-Lot Cell Phone Company provides phone services for its customers. Create an abstract class named PhoneCall that includes a String field for a phone number and a double field for the price of the call. Also include a constructor that requires a
> Create an abstract class named Book. Include a String field for the Book’s title and a double field for the book’s price. Within the class, include a constructor that requires the book title, and add two get methods—one that returns the title and one tha
> Create a class named Rock that acts as a superclass for rock samples collected and catalogued by a natural history museum. The Rock class contains fields for a number of samples, a description of the type of rock, and the weight of the rock in grams. Inc
> Create a class named BaseballGame that contains data fields for two team names. Include a two-dimensional array that can hold the scores for each of two teams in each inning of the game. The BaseballGame class includes a final int that represents the n
> Create a class named Poem that contains fields for the name of the Poem and the number of lines in it. Include a constructor that requires values for both fields. Also include get methods to retrieve field values. Save the file as Poem.java. b. Create th
> Create a TeeShirt class for Tamjeed’s Tee Shirt Company. Fields include an order number, size, color, and price. Create set methods for the order number, size, and color, and create get methods for all four fields. The price is determined by the size: $2
> In Chapter 9, you created an interactive LessonWithRentalDemo class that obtains data for four rentals from Sunshine Seashore Supplies, including details about the contract number, length of the rental, and equipment type. After data entry, the applicati
> Create a class named Candle for a candle-making business. Include data fields for color, height, and price. Create get methods for all three fields. Create set methods for color and height, but not for price. Instead, when height is set, determine the pr
> Create a record named Inventor that stores two Strings: the name of an inventor and the inventor’s country of origin. Save the file as Inventor.java. b. Create an Invention class with three fields: a String description of the invention, an Inventor objec
> Create an interface called Runner. The interface has an abstract method called run(). Save the file as Runner.java. b. Create classes called Machine, Athlete, and PoliticalCandidate that all implement Runner. The run() method displays a message describin
> Create an abstract class called GeometricFigure. Each figure includes a height, a width, and a String figure type. Include an abstract method to determine the area of the figure. Save the file as GeometricFigure.java. b. Create two subclasses of Geometr
> Create an interface named Turner, with a single method named turn(). Save the file as Turner.java. b. Create a class named Leaf that implements turn() to display Changing colors. Create a class named Page that implements turn() to display Going to the ne
> Create a class named Blanket with fields for a Blanket’s size, color, material, and price. Include a constructor that sets default values for the fields as Twin, white, cotton, and $30.00. Include a set method for each of the first three fields. The meth
> Create an abstract Division class with fields for a company’s division name and account number, and an abstract display() method. Use a constructor in the superclass that requires values for both fields. Save the file as Division.java. b. Create two sub
> Create a class named Horse that contains data fields for the name, color, and birth year. Include get and set methods for these fields. Save the file as Horse.java. b. Create a subclass of Horse named RaceHorse, which contains an additional field that ho
> Create a class named Purchase. Each Purchase contains an invoice number, amount of sale, and amount of sales tax. Include set methods for the invoice number and sale amount. Within the set method for the sale amount, calculate the sales tax as 5 percent
> Create a personal phone directory that contains room for first names and phone numbers for 30 people. Assign names and phone numbers for the first 10 people. Prompt the user for a name, and if the name is found in the list, display the corresponding phon
> In Chapter 9, you created a DinnerEventDemo class that obtains user data for an array of dinner events for Yummy Catering and allows the user to sort the events using various criteria. Now, modify the application so that it becomes immune to user data en
> Write an application that allows a user to enter the names and birthdates of up to 10 friends. Continue to prompt the user for names and birthdates until the user enters the sentinel value ZZZ for a name or has entered 10 names, whichever comes first. Wh
> Create a CollegeCourse class. The class contains fields for the course ID (for example, CIS 210), credit hours (for example, 3), and a letter grade (for example, A). Include get and set methods for each field. Save the file as CollegeCourse.java. b. Cre
> Create a class named Salesperson. Data fields for Salesperson include an integer ID number and a double annual sales amount. Methods include a constructor that requires values for both data fields, as well as get and set methods for each of the data fiel
> Create an application that prompts a user for 10 integers and stores them in an array. The application should call five methods that in turn (1) display all the integers, (2) display all the integers in reverse order, (3) display the sum of the intege
> Write an application for Chapa’s Car Care Shop that shows a user a list of available services: oil change, tire rotation, battery check, or brake inspection. Allow the user to enter a string that corresponds to one of the options, and display the option
> Allow a user to enter any number of double values up to 15. The user should enter 99999 to quit entering numbers. Display an error message if the user quits without entering any numbers; otherwise, display a count of the numbers entered, the arithmetic a
> Create a program with an enumeration that contains the names of the eight planets in our solar system. Prompt the user for a planet name and use the ordinal() method to display the planet’s position. Save the file as Planets.java.
> Create an application that contains an enumeration that represents the days of the week. Display a list of the days, and then prompt the user for a day. Display business hours for the chosen day. Assume that the business is open from 11 to 5 on Sunday, 9
> Write an application that stores at least five different college courses (such as CIS101), the time it first meets in the week (such as Mon 9 am), and the instructor (such as Khan) in a two-dimensional array. Allow the user to enter a course name and dis
> Radio station KJAVA wants a class to keep track of recordings it plays. Create a class named Recording that contains fields to hold methods for setting and getting a Recording’s title, artist, and playing time in seconds. Save the file as Recording.java.
> In Chapter 8, you created a Rental class for Sunshine Seashore Supplies. Now extend the class to create a LessonWithRental class. In the extended class, include a new boolean field that indicates whether a lesson is required or optional for the type of e
> The mean of a list of numbers is its arithmetic average. The median of a list is its middle value when the values are placed in order. For example, if an ordered list contains 1, 2, 3, 4, 5, 6, 10, 11, and 12, then the mean is 6, and their median is 5. W
> Write an application containing an array of 15 String values. Accept any number of Strings up to 15 from a user, and display them in ascending order. Save the file as StringSort.java.
> Each week, the Pickering Trucking Company randomly selects one of its 30 employees to take a drug test. Write an application that determines which employee will be selected each week for the next 52 weeks. Use the Math.random() function explained in Appe
> Write an application that stores nine integers in an array named numbers. Display the integers from first to last, and then display the integers from last to first. Save the file as NineInts.java.
> Write an application that accepts up to 20 Strings, or fewer if the user enters a terminating value. Store each String in one of two lists—one list for short Strings that are 10 characters or fewer and another list for long Strings that are 11 characters
> Write an application that accepts a word from a user and converts it to Pig Latin. If a word starts with a consonant, the Pig Latin version removes all consonants from the beginning of the word and places them at the end, followed by ay. For example, cri
> Three-letter acronyms are common in the business world. For example, in Java you use the IDE (Integrated Development Environment) in the JDK (Java Development Kit) to write programs used by the JVM (Java Virtual Machine) that you might send over a LAN (l
> Write an application that accepts three Strings from the user and, without regard to case, appropriately displays a message that indicates whether the Strings were entered in alphabetical order. Save the file as Alphabetize.java. b. Write an application
> Write an application that counts the words in a String entered by a user. Words are separated by any combination of spaces, periods, commas, semicolons, question marks, exclamation points, or dashes. Figure 7-17 shows a typical execution. Save the file
> Write an application that prompts the user for a password that contains at least two uppercase letters, at least three lowercase letters, and at least one digit. Continually reprompt the user until a valid password is entered. Display a message indicatin
> Create a Card class that holds a suit and value for each Card object. Save the file as Card.java. b. Create an abstract CardGame class similar to the one described in this chapter. The class contains a virtual deck of 52 playing cards that uses a Card cl
> Create a program that contains a String that holds your favorite inspirational quote and display the total number of spaces contained in the String. Save the file as CountSpaces.java. b. Write an application that counts the total number of spaces contain
> Write an application that prompts the user for three first names and concatenates them in every possible two name combination so that new parents can easily compare them to find the most pleasing baby name. Save the file as BabyNameComparison.java.
> Create a TaxReturn class with fields that hold a taxpayer’s Social Security number, last name, first name, street address, city, state, zip code, annual income, marital status, and tax liability. Include a constructor that requires argu
> Write an application that determines whether a phrase entered by the user is a palindrome. A palindrome is a phrase that reads the same backward and forward without regarding capitalization or punctuation. For example, Dot saw I was Tod, Was it a car or
> Write a program that inserts parentheses, a space, and a dash into a String of 10 user-entered numbers to format it as a phone number. For example, 5153458912 becomes (515)345-8912. If the user does not enter exactly 10 digits, display an error message.
> Modify the CharacterInfo class shown in Figure 7-3 so that the tested character is retrieved from user input. Save the file as InputCharacterInfo.java.
> The Freemont Automobile Factory has set a goal that each worker will eventually produce 10,000 parts per month. The company has discovered that the longer a worker has been on the job, the more parts the worker can produce. Write an application that prom
> Write an application that allows a user to enter any number of student quiz scores until the user enters a sentinel 99. If the score entered is less than 0 or greater than 10, display an appropriate message and do not use the score. After all the scores
> Accept a digit from the user, then display a seven-line triangle pattern that uses the digit. Figure 6-33 shows a typical execution. The program can contain no more than three output statements. Save the file as TriangleWithLoops.java.
> Which of the following can be specified by using a parameter in one or more versions of the JTextField constructor? a. the initial text in the field b. requiring that the value entered be nonnumeric c. requiring that the entered value be numeric d. makin
> In previous chapters, you developed classes that hold rental contract information for Sunshine Seashore Supplies. Now modify the Rental class to include an integer field that holds an equipment type. Add a final String array that holds names of the types
> A JFrame is a descendant of each of the following classes except the _________________ class. a. Component b. Container c. Jar d. Window 2. Unlike a Window, a JFrame _________________. a. has a title bar and border b. can be made visible c. can have des
> The method that can be used to sort an ArrayList is _________________. a. Collections.sort() b. ArrayList.sort() c. List.sort() d. Sorting.sort() 12. All of the following classes contain a built-in compareTo() method except _________________. a. Integer
> In programming, a(n) _________________ is a group of objects that can be operated on together. a. collision b. anthology c. assemblage d. collection 2. A difference between a collection and an array is that a collection _________________. a. can hold re