Answered step by step
Verified Expert Solution
Link Copied!

Question

00
1 Approved Answer

The goal of this assignment is to use loop patterns to solve a variety of problems Starting 1. In Eclipse, create a new project or

image text in transcribedimage text in transcribed

The goal of this assignment is to use loop patterns to solve a variety of problems Starting 1. In Eclipse, create a new project or use an assignments one. Add a package a4, and a class SearchAndOptimizingLoops to that package. Copy and paste Picture.java and an image file from prior work into this package (Picture.java should update itself to the a4 package) 2. In your class, implement the static methods specified below 3. All methods you write should have a Javadoc comment with a description of what the method does and a @param for each parameter and a @return describing what information is returned 4. Add a main method with tests for each method. Your tests should cover possible return values (such as true or false) as well as special cases (for example, empty strings). Your tests should print what was expected as well as the actual result from the method in a neatly formatted way 5. You do not need to test for cases that are prohibited in the description. If the description says that there is at least X in the parameter, then you do not need to test for the truth of that constraint. 6. None of your methods except for main may print anything to the console 7. Ensure you have consistent spacing and indenting in your file, proper and consistent indenting, and a Javadoc comment about the start of the class definition with your name, assignment number and class Required Methods You must implement each of the described methods with method name, return type and parameters carefully checked against the specification. When parameters are specified you must use the order they are listed in. You may implement additional methods if they aid your problem-solving 1. Method name: findSmallestPositiveNumber Parameter(s): A String containing integer numbers separated by spaces. There must be at least one positive number in the String Return value: An int value that is the smallest number greater than 0 in the input string Example: findSmallestPositiveNumber("2 -4 5") should return 2 Note: Even though I put this first, I would consider working on this later. The other methods are basically just applying the patterns we looked at in class. This one is similar but requires a little more working out the logic of the problem 2. Method name: lowestAlphabetically Parameter(s): A String of lower-case words separated by spaces and made up of the letters a-z. The String will have at least one word Return value: A String containing the lowest alphabetical word. The String method compareTo0 does a lexicographic comparison between two strings, which allows you to test for the lowest alphabetical word Read documentation on compareTo) in order to understand how to use it. Example: lowestAlphabetically("cat dog apple fish") would return "apple". 3. Method name: findSmallestNumberinTwoStrings Parameters): Two String parameters. Each string is made up of numbers separated by spaces. The first string must have at least one number. Return value: An int containing the smallest number found in the two strings. Example: findSmallestNumberlnTwoStrings( 12 3 5", "2-1 10") would return -1. 4. Method name: curveScores Parameter(s): A String containing numbers from 0 to 100. Each number is separated by a space. There must be at least one number in the String. Return value: A String of numbers scaled so that the highest number in the parameter String becomes 100 and all the other numbers are moved up by the same amount. This String should also be numbers separated by spaces with no additional characters. Example: curveScores("45 85 90") would return "55 95 100". 5. Method name: containsThisColor Parameter(s): A Picture object that is at least 1x1 pixels and a Color object. Return value: A boolean value. Return true if the Color parameter matches one of the pixels in the image and false otherwise. A color match is done by using the .equals method rather than, Example: For a 1 pixel picture with a color of (100, 200, 50) and a color to search for of (100, 100, 100), this method would return false

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions