Question: Write a new program called TrickOr Treat that will do the following 1. In a while loop, say Trick or Treat! and allow the user
Write a new program called TrickOr Treat that will do the following 1. In a while loop, say "Trick or Treat!" and allow the user to type in the name of a candy and store it in an ArrayList. Once the user types "Trick", then the loop should stop. Then, print out the total number of candies on the screen. (See example below) [1 points] 2. Write a method called countSnickers that will take an ArrayList of candy as an argument, and return the total number of Snickers candy you have You should print out this value in the main method. [2 points] 3. Overload the countSnickers method to take a conventional array (not ArrayList) of candy as an argument, and return the total number of Snickers candy you have. We will not use this method, just create it only. [1 points] 4. Write another method called search that will take two arguments: an ArrayList of candy and the name of one candy. In the main method, ask the user which candy do you want to search for, and then pass the ArrayList along with the name of the candy that the user typed to the search method The search method will loop through the array and print out how many of those candies exist (See example below). [2 points]
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
