$30
CECS 328
Lab Programming Assignment #2
Points Possible: 20
Submission Requirements:
• You can work in teams up to 3. If working in teams, only one person should submit the required
file.
o If working in a team, adhere to social distancing and collaborate remotely over the
phone and internet.
• You should submit just one file, and that file’s name should be:
o Search.java
• Submitting a file with any other name will get you points deducted. Do not zip the file either.
• Because the Java file name should be what’s listed above, the top-level class name within it
should also be named Search.
• Within the java file, include your name (at the top as a comment). If working in a team, the full
names of all team members must also be within the Java file (at the top as a comment).
• In addition, all team member names need to be listed on the submission in BeachBoard, as a
comment.
• Submit the Java file to BeachBoard. No email submissions will be accepted.
• The project must be in the Java programming language.
o I test with JDK version 14.0.2 and the expectation is that your code works with that
version. Otherwise, you will get points deducted.
• I should be able to both pass in arguments and run your program via the command line.
• Ensure the Java keyword “package” doesn’t exist in your java file before you submit your code.
That will prevent me from properly testing your code, so remove it before submitting your code.
Program Requirements:
Implement a search algorithm such that it will take an input string, search a text file, and then output
the first found variation of that input string along with the line number. By variation, I’m referring to a
scrambling combination of the word would result in a match. For example, if I search for “cat”, then it
would be valid if “atc” is outputted as the search result. If the string is not found in the text file, then
“String not found” should be outputted. Searches should also be case insensitive. For example, if I
search for “cat”, then it would be valid if “acT” is outputted as the search result.
Clarifications:
1. Input file would have up to 100 strings. Each string is on a separate line, so there will be up to
100 lines in the text file.
2. A small example file will be uploaded to BeachBoard. Note, it’s just an example. I will have my
own input file that I’ll test with. The example file will give you an idea of the formatting of the
file and the types of strings I’ll be testing with.
3. For both the search string and strings in the input file, the strings will only contain alphabets.
4. The program must complete execution within 1 minute.
5. The input file name must be “input.txt”.
6. You can utilize any search algorithm you’d like (e.g. linear search).
CECS 328 Fall 2020 Instructor: Ali Sharifian
2 of 2
7. Just to reiterate, the program should be able to be run from the command line.
o The first parameter will be the input file name “input.txt” (which will be in the same
directory as the Java file).
o The second parameter will be the search string.
8. The output should contain the first matching string found and the line number it was found in.
The first line number of the input text file is 1. If the string isn’t found in the input file, then
“String not found” should be outputted.
9. The formatting of the input and output must match exactly the formatting of the below
examples.
I will be testing your code via the command line so it is a requirement that your code be able to take in
arguments and execute via the command line. Failure to do this will result in zero credit.
Comment your code enough so that in case it doesn’t work, I can see what you’re trying to do and
possibly give you partial credit.
Examples:
The below examples use the input.txt file uploaded to BeachBoard.
C:\MyFolder> java Search input.txt AMzY
Found search string: YamZ
Line Number: 3
C:\MyFolder> java Search input.txt sKDJAFDFA
Found search string: AKDJAFDSF
Line Number: 10
C:\MyFolder> java Search input.txt er
Found search string: er
Line Number: 15
C:\MyFolder> java Search input.txt ER
Found search string: er
Line Number: 15
C:\MyFolder> java Search input.txt hello
String not found
Failure to follow the above requirements may result in substantial point deduction, up to and
including receiving zero credit. I recommend you read the instructions more than once to ensure your
program meets the requirements.
Grading Guidelines:
• Does the program meet the requested requirements/criteria?
• Are the submission instructions followed?
• Does your code compile?
• Does your code pass my test cases? Note that I do not share my test cases.