Given a String input of fruits, find the fruit in the list that is not listed...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Given a String input of fruits, find the fruit in the list that is not listed in alphabetical order. Print out the position in the list and name of the odd fruit out using the formatting included in the Testing section. Valid Assumptions: There will always be exactly one fruit in the String which violates alphabetical order. There will also be at least 2 fruits in the list. All letters will be lowercase. Sample Output Test 1 Hello, welcome to the Odd Fruit Out game! Please enter a String of fruits separated by commas. [apple, orange, banana] The odd fruit out is fruit number 3: banana Sample Output Test 2 Hello, welcome to the Odd Fruit Out game! Please enter a String of fruits separated by commas. [apple, banana, orange, kiwi, pineapple] The odd fruit out is fruit number 4: kiwi We have also included a program that will allow you to create and run output tests automatically in the Starter Code. This will make it easier for you to verify that each possible progression through your solution is correct. Take a look at RunLocalTest.java. There are many utility features and tools that you do not need to worry about at the moment, instead, focus on the test case (included below): @Test(timeout=1000) public void testExpectedOne() { // set the input string input = "apple, strawberry, mango "; // Pair the input with the expected result string expected = WELCOME MESSAGE + " " + PROMPT + " " + RESULT + "3: mango "; // Runs the program with the input values receive Input(input); OddFruitout.main(new String[e]); // Retreives the output from the program string stuout getoutput(); // Trims the output and verifies it is correct. stuout=stuout.replace(" ", " "); assertEquals("Make sure you print the correct fruit!", expected.trim(), stuout.trim()); Given a String input of fruits, find the fruit in the list that is not listed in alphabetical order. Print out the position in the list and name of the odd fruit out using the formatting included in the Testing section. Valid Assumptions: There will always be exactly one fruit in the String which violates alphabetical order. There will also be at least 2 fruits in the list. All letters will be lowercase. Sample Output Test 1 Hello, welcome to the Odd Fruit Out game! Please enter a String of fruits separated by commas. [apple, orange, banana] The odd fruit out is fruit number 3: banana Sample Output Test 2 Hello, welcome to the Odd Fruit Out game! Please enter a String of fruits separated by commas. [apple, banana, orange, kiwi, pineapple] The odd fruit out is fruit number 4: kiwi We have also included a program that will allow you to create and run output tests automatically in the Starter Code. This will make it easier for you to verify that each possible progression through your solution is correct. Take a look at RunLocalTest.java. There are many utility features and tools that you do not need to worry about at the moment, instead, focus on the test case (included below): @Test(timeout=1000) public void testExpectedOne() { // set the input string input = "apple, strawberry, mango "; // Pair the input with the expected result string expected = WELCOME MESSAGE + " " + PROMPT + " " + RESULT + "3: mango "; // Runs the program with the input values receive Input(input); OddFruitout.main(new String[e]); // Retreives the output from the program string stuout getoutput(); // Trims the output and verifies it is correct. stuout=stuout.replace(" ", " "); assertEquals("Make sure you print the correct fruit!", expected.trim(), stuout.trim());
Expert Answer:
Posted Date:
Students also viewed these programming questions
-
What other cost factors might you include in such an economic analysis? The proposed small office building in Example 3-2 has 24,000 net square feet of area heated by a natural gas furnace. The owner...
-
Explain why we should study the crystal structure of metals.
-
Match each of the numbered descriptions with the principle it best reflects. Indicate your answer by writing the letter for the appropriate principle in the blank space next to each description. A....
-
Using the compact storage technique described in Section 6.8, determine the vectors DIAG, OFFDIAG, COL, and ROW for the following matrix: \[\mathbf{S}=\left[\begin{array}{cccccc}17 & -9.1 & 0 & 0 &...
-
You are a senior with Tick and Bop, Public Accountants. Stupendous Soups is one of your clients, and your firm prepares a compilation report for the company for income tax purposes. Stupendous Soups...
-
Please help with investment Colonial Pharmaceuticals is a small firm specializing in new products. It is organized into two divisions, which are based on the products they produce. AC Division is...
-
Report on drivers and barriers of social sustainability for low tier suppliers. It should be on a particular country with data, analysis and conclusion.
-
What exactly does Krueger mean by "income mobility," and more precisely "intergenerational income mobility," and why is this notion so crucial to him in combating income inequality? What does this...
-
Bayer estimates the current global market for seeds at 40 billion and the market for crop protection at 50 billion. Bayer's digital platform will provide guidance from "precision" agriculture and...
-
e 1. What are the basal characteristics of animals? 2. Sponges do not have tissues or organs. But they do have specialized cells. Using your lab book and the film, briefly describe the function of...
-
Complete the following question: A: What biome do we live in here in southern California?What characterizes our biome? B: In which biomes is fire a major factor? What is therole of fire in these...
-
In cats, coat color is codominant. If a black cat mates with a spotted black and white cat, what is the probability of having a cat with a black coat?
-
Mighty Manny, Incorporated manufactures ice scrapers and distributes them across the midwestern United States. Mighty Manny is incorporated and headquartered in Michigan. It has product sales to...
-
Critical reading SAT scores are distributed as N(500, 100). a. Find the SAT score at the 75th percentile. b. Find the SAT score at the 25th percentile. c. Find the interquartile range for SAT scores....
-
Explain at least three ways to reduce ATM fees charged to your account. Also describe the trade-offs involved in each action. Write About It Create a list with your explanations.
-
Bank X offers a checking account with a minimum balance of \($300\), but does not charge fees nor give interest. Bank Ys minimum balance is \($50\), but it charges a fee of \($25\) if you have more...
-
List the steps to take to use a checking account effectively.
Study smarter with the SolutionInn App