Question: Java Write a method testCoffeeDrinks that takes one parameter: - drinks, an non-empty array of CoffeeDrink objects The method finds and prints to the screen

Java

Write a method testCoffeeDrinks that takes one parameter:

- drinks, an non-empty array of CoffeeDrink objects

The method finds and prints to the screen the strongest drink (You must use the compareTo method for full credit). If more than one such drink occur in the array, pick the first one. The method also creates, populates and returns an array of integers containing the frequency of each possible coffee strength (1-5), in the drinks array. For example, if the information of the drinks in the array is given in the table below:

Coffee Drink Number Ingredient1 Ingredient2 0 coffee, 4 milk, 3 1 coffee, 2 milk, 3 2 coffee, 2 milk, 1 3 coffee, 4 milk, 1 4 coffee, 3 milk, 2 5 coffee, 4 milk, 4

The program will display: coffee strength:4 milk strength: 1

And return the array {0,2,1,3,0}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!