Scoops Ahoy wants a program to analyze their ice cream flavors. Write a program called IceCreamAnalysis.java...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Scoops Ahoy wants a program to analyze their ice cream flavors. Write a program called IceCreamAnalysis.java that will contain several methods. Your program will have several parallel arrays in the main method which you will use in the program. The data in each array is related to the other arrays by its position in the array; thus, for example, the ice cream flavor Vanilla has a favorability of 0.78, which means that 78 out of 100 Scoops Ahoy's customers like Vanilla. Below are the arrays that you will need. I also attached them in a text file. Please note that these are sample arrays. When we test your program, we will be using different arrays. String array of ice cream flavors: Vanilla Chocolate Mint Cookies Strawberry Cookie Chocolate N' Cream Dough Chip Double array of favorability: 0.78 0.62 0.59 0.33 Double array of calories per serving: 137.6 143.5 151.3 2.23 162.8 Double array of production cost per gallon: 1.98 2.14 2.17 Your program will contain several methods: 0.45 126.6 2.09 0.67 168.4 2.12 Salted Caramel 0.72 139.1 2.07 Moose Tracks 0.49 158.2 2.34 Double array of production cost per gallon: 1.98 2.14 2.17 2.23 2.09 2.12 2.07 2.34 Your program will contain several methods: The first method, calcMean(), calculates the average of all the values in the double array passed into the method. This method passes in a double array and returns the average as double. The method header is: public static double calcMean (double [] values) The second method, findGreatest(), searches the double array passed in to find the greatest value from the array This method passes in a double array and returns the greatest double value found in the array. The method header is: public static double findGreatest (double [] values) The third method, findSmallest(), searches the double array passed in to find the smallest value from the array This method passes in a double array and returns the smallest double value found in the array. The method header is: public static double findSmallest (double[] values) The fourth method, findBestValue(), passes in a String array of ice cream flavors, a double array of favorability and a double array of cost per gallon. It will walk through the double arrays to compute a value rating. This will need to be stored in a new array. The calculation for the value rating is: favorability * (5 cost per gallon). It will then search through the value ratings to find the ice cream flavor with the highest value rating. It will return a String that contains the ice cream flavor associated with the highest value rating in the new array. The method header is: public static String findBestValue (String [] flavors, double [] favorability, double [] cost) The fifth method, findSmallestTwo(), passes in a String array of ice cream flavors and a double array of values. It will search through the double array to find the two smallest values in the double array. It will return a String array that contains the ice cream flavors associated with the smallest two double values in the double array, with the flavor with the smallest value listed first. The method header is: public static String[] findSmallestTwo (String[] flavors, double [] values) The sixth method, findFlavor(), will verify if a given String is a valid ice cream flavor within the String array of ice cream flavors. This method passes in the String array of ice cream flavors and the flavor being searched for. The method returns a boolean value of true or false based on whether the flavor was found within the ice cream flavors array. If the ice cream flavor is in the array, the method will return a value of true, and, if the ice cream flavor is not in the array, the method will return false. Note, the ice cream flavors must match exactly for the method to return true. The method header is: The main method will contain the arrays needed for the program. This method will also do the following: public static boolean findFlavor (String[] flavors, String flavor) Call the calcMean() method, passing it the double array of calories per serving and print out the results. Call the calcMean() method, passing it the double array of cost per gallon and print out the results. Call the findGreatest() method, passing it the double array of favorability and print the results do the following: Call the calcMean() method, passing it the double array of calories per serving and print out the results. Call the calcMean() method, passing it the double array of cost per gallon and print out the results. Call the findGreatest() method, passing it the double array of favorability and print the results. Call the findSmallest() method, passing it the double array of cost per gallon and print the results. Call the findBestValue() method, passing it the String array of ice cream flavors, the double array of favorability and the double array of cost per gallon and print the results. Call the findSmallestTwo () method, passing it the String array of ice cream flavors and the double array of calories and print the results. (Note: You will need to use an enhanced for loop to print out the values from the array.) Ask the user for an ice cream flavor. Call the findFlavor(), passing it the String array of ice cream flavors and the given flavor and print the results. All outputs should be rounded to three decimal spaces using printf(). Scoops Ahoy wants a program to analyze their ice cream flavors. Write a program called IceCreamAnalysis.java that will contain several methods. Your program will have several parallel arrays in the main method which you will use in the program. The data in each array is related to the other arrays by its position in the array; thus, for example, the ice cream flavor Vanilla has a favorability of 0.78, which means that 78 out of 100 Scoops Ahoy's customers like Vanilla. Below are the arrays that you will need. I also attached them in a text file. Please note that these are sample arrays. When we test your program, we will be using different arrays. String array of ice cream flavors: Vanilla Chocolate Mint Cookies Strawberry Cookie Chocolate N' Cream Dough Chip Double array of favorability: 0.78 0.62 0.59 0.33 Double array of calories per serving: 137.6 143.5 151.3 2.23 162.8 Double array of production cost per gallon: 1.98 2.14 2.17 Your program will contain several methods: 0.45 126.6 2.09 0.67 168.4 2.12 Salted Caramel 0.72 139.1 2.07 Moose Tracks 0.49 158.2 2.34 Double array of production cost per gallon: 1.98 2.14 2.17 2.23 2.09 2.12 2.07 2.34 Your program will contain several methods: The first method, calcMean(), calculates the average of all the values in the double array passed into the method. This method passes in a double array and returns the average as double. The method header is: public static double calcMean (double [] values) The second method, findGreatest(), searches the double array passed in to find the greatest value from the array This method passes in a double array and returns the greatest double value found in the array. The method header is: public static double findGreatest (double [] values) The third method, findSmallest(), searches the double array passed in to find the smallest value from the array This method passes in a double array and returns the smallest double value found in the array. The method header is: public static double findSmallest (double[] values) The fourth method, findBestValue(), passes in a String array of ice cream flavors, a double array of favorability and a double array of cost per gallon. It will walk through the double arrays to compute a value rating. This will need to be stored in a new array. The calculation for the value rating is: favorability * (5 cost per gallon). It will then search through the value ratings to find the ice cream flavor with the highest value rating. It will return a String that contains the ice cream flavor associated with the highest value rating in the new array. The method header is: public static String findBestValue (String [] flavors, double [] favorability, double [] cost) The fifth method, findSmallestTwo(), passes in a String array of ice cream flavors and a double array of values. It will search through the double array to find the two smallest values in the double array. It will return a String array that contains the ice cream flavors associated with the smallest two double values in the double array, with the flavor with the smallest value listed first. The method header is: public static String[] findSmallestTwo (String[] flavors, double [] values) The sixth method, findFlavor(), will verify if a given String is a valid ice cream flavor within the String array of ice cream flavors. This method passes in the String array of ice cream flavors and the flavor being searched for. The method returns a boolean value of true or false based on whether the flavor was found within the ice cream flavors array. If the ice cream flavor is in the array, the method will return a value of true, and, if the ice cream flavor is not in the array, the method will return false. Note, the ice cream flavors must match exactly for the method to return true. The method header is: The main method will contain the arrays needed for the program. This method will also do the following: public static boolean findFlavor (String[] flavors, String flavor) Call the calcMean() method, passing it the double array of calories per serving and print out the results. Call the calcMean() method, passing it the double array of cost per gallon and print out the results. Call the findGreatest() method, passing it the double array of favorability and print the results do the following: Call the calcMean() method, passing it the double array of calories per serving and print out the results. Call the calcMean() method, passing it the double array of cost per gallon and print out the results. Call the findGreatest() method, passing it the double array of favorability and print the results. Call the findSmallest() method, passing it the double array of cost per gallon and print the results. Call the findBestValue() method, passing it the String array of ice cream flavors, the double array of favorability and the double array of cost per gallon and print the results. Call the findSmallestTwo () method, passing it the String array of ice cream flavors and the double array of calories and print the results. (Note: You will need to use an enhanced for loop to print out the values from the array.) Ask the user for an ice cream flavor. Call the findFlavor(), passing it the String array of ice cream flavors and the given flavor and print the results. All outputs should be rounded to three decimal spaces using printf().
Expert Answer:
Related Book For
Probability and Statistical Inference
ISBN: 978-0321923271
9th edition
Authors: Robert V. Hogg, Elliot Tanis, Dale Zimmerman
Posted Date:
Students also viewed these programming questions
-
The organizing committee for the HCC Celebrates Columbia's 50th Birthday, Inc., has planned a special event commemorating notable people originally from Columbia, MD. The committee has invited the...
-
What is meant by date alignment? Does it exist on the consolidated worksheet under the following methods, and if not, how is it created prior to elimination of the investment account under each of...
-
What will a spring scale read for the weight of a 58.0-kg woman in an elevator that moves? (a) Upward with constant speed 5.0 m / s, (b) Downward with constant speed 5.0 m / s, (c) With an upward...
-
What controlling issues does an entrepreneur need to be aware of?
-
Pick an industry and a product or service. Engage in a creative-thinking process, as outlined in Chapter 11, to generate an improved offering. Do the same to create an entirely new offering that uses...
-
(Three Differences, No Beginning Deferred Taxes, Multiple Rates) The following information is available for Rammers Corporation for 2010. 1. Depreciation reported on the tax return exceeded...
-
Oxygen gas having a volume of 1250 cm 3 at 43.1 C and 1.04 x 10 5 Pa expands until its volume is 1900 cm 3 and its press is 1.08 x 10 5 Pa. Find: (a) the number of moles of oxygen present and (b) the...
-
On January 1, 2020, Wildhorse Leasing Inc., a lessor that uses IFRS 16, signed an agreement with Rock River Inc., a lessee, for the use of a compression system. The system cost $424,000 and Wildhorse...
-
Ms. Ginger is the CEO of Jar Inc., an event-planning CCPC in Canada. Her husband, Mr. Rolo, has a lot of expertise in this business and would like to become involved in Jar Inc. Rolo has saved up...
-
How is Machine Learning related to Artificial Intelligence? 2. Discuss how deep learning works 3. How does Reinforcement Learning work? Explain with an example 4. Explain the components of Expert...
-
Evaluate the following function at the values f(5), f(-1), and f(x+h). f(x)=x2+x+1
-
2.[10 points] Catherine deposits $P into a savings account on the first day of each month for the next 35 years (420 investments). Afterwards, she plans to retire and to withdraw a fixed amount of...
-
For investors, credit rating agencies provide independent, easy-to-use measurements of relative credit risk. The most well-known credit rating agencies are ______. (Check all that apply.) Multiple...
-
What is the future value of $350 today invested for 7 years earning 11% interest? An annuity pays $11,000 per year for 10 years. At a 4% discount rate, what is it worth today? A share of...
-
A corporation has an overdue bonds payable of P3,000,000. The note was dated January 1, 2018. It has an annual interest rate of 10%, and interest is paid December 31 of each year. The corporation...
-
Where are the olfactory sensory neurons, and why is that site poorly suited for their job?
-
Let X1, X2, ... , Xn be a random sample from an exponential distribution with mean θ. Show that the likelihood ratio test of H0: θ = θ0 against H1:...
-
By squaring the binomial expression [(Yi ) (SxY/s2x)(xi )], show that ri i-1 i=1 equals (n-1)S,(1-R2), where Xi = xi,X2 = X2, ,
-
Let X equal the forced vital capacity (FVC) in liters for a female college student. (The FVC is the amount of air that a student can force out of her lungs.) Assume that the distribution of X is...
-
Assume that the economy can experience four possible states: high growth, normal growth, recession, or depression. For each of those states, you expect the following stock market returns for the...
-
Suppose an investment pays off $800 or $1,600 with equal probability per $1,000 invested. What is the maximum leverage ratio you could have and still have enough to repay the loan in the event the...
-
The imposition of new trade tariffs has resulted in tensions between the United States and some of its major trading partners. Suppose you are a small business owner in the United States. a. How...
Study smarter with the SolutionInn App