Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Readings In Database Systems

Authors: Michael Stonebraker

2nd Edition

0934613656, 9780934613651

More Books

Students also viewed these Databases questions

Question

Is the current human resources management system obsolete?

Answered: 1 week ago