Need help writing this java code, it has three objectives: to process strings to compare, search, sort, and verify location of specific pattern to output result via interface Description Write a Java program to read a text file (command line input for file name), process the text file and perform the following. Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.) Print the total number of different words (case sensitive, meaning “We” and “we” are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.) Print all words in ascending order (based on the ASCII code) without duplication. Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file. Print all line(s) with line number(s) where the word is found by invoking the method of 4). Under each output line indicate the location(s) of the first character of the matched word (refer to the output example below). Empty lines are lines, they also have their own unique line numbers. Repeat the pattern match (4 and 5 above) until user types in EINPUT. Important Note: Must construct searching and sorting methods and use them to perform sorting and searching. Do not use built-in methods as Collection.sort or classes such as ArrayList. Can use Built-in String methods such as equals, compareTo, indexOf, split, or others found useful. Construct a method to extract tokens (words) from either character arrays or strings. Also can construct a Class using an array of strings or array of character arrays (char array) to store the original text from the input the file
Need help writing this java code, it has three objectives:
- to process strings
- to compare, search, sort, and verify location of specific pattern
- to output result via interface
Description
Write a Java program to read a text file (command line input for file name), process the text file and perform the following.
- Print the total number of words in the file. (When using java_test.txt, I calculate the number of words, including number, as 254.)
- Print the total number of different words (case sensitive, meaning “We” and “we” are two different words) in the file. (When using java_test.txt, I calculate the number of different words, including number, as 168.)
- Print all words in ascending order (based on the ASCII code) without duplication.
- Write a pattern match method to find the location(s) of a specific word. This method should return all line number(s) and location(s) of the word(s) found in the file.
- Print all line(s) with line number(s) where the word is found by invoking the method of 4). Under each output line indicate the location(s) of the first character of the matched word (refer to the output example below).
- Empty lines are lines, they also have their own unique line numbers.
- Repeat the pattern match (4 and 5 above) until user types in EINPUT.
Important Note:
- Must construct searching and sorting methods and use them to perform sorting and searching. Do not use built-in methods as Collection.sort or classes such as ArrayList. Can use Built-in String methods such as equals, compareTo, indexOf, split, or others found useful.
- Construct a method to extract tokens (words) from either character arrays or strings.
- Also can construct a Class using an array of strings or array of character arrays (char array) to store the original text from the input the file
A word is defined by any combination of alpha (upper or lower case) and numerical characters, all other characters are delimiters.
Input
The name of the text file should be read in from the Command line arguments.
Output (Example of execution of your program)
java Project mytext.txt
The total number of word in the file is: 501
The total number of different words in the file is: 465
Words of the input file in ascending order without duplication:
// here are output of all words in ascending order without duplication
// (the content of this portion is subject to the input text file)
Please enter a word to be searched: system <Enter>
Line number 10
complete your computation a 64 bit processor system running Linux
Line number 487
entire system should be based on a complete software system infrastructure design.
Please enter a word to be searched: California <Enter>
The word Caliornia is not found in the text file.
Please enter a word to be searched: EINPUT <Enter>
Bye!
Note: the blue color text indicates user input and <Enter> means user hit the <Enter> key
Specifications
This program must meet the following specifications:
- The name of the your source file that contain method main() must be java
- Name it exactly: upper/lower case letters are important!
- The output must match the example shown above, including white space and capitalization.
- Name your java program java
- You may not use ArrayLists. You can and should use String arrays. You must calculate in the code the size that is needed for these arrays. As in, you may not preset the array sizes using literal values in the code.
java_test.txt
James Gosling, Mike Sheridan, and Patrick Naughton initiated
the Java language project in June 1991.[23] Java was originally
designed for interactive television, but it was too advanced
for the digital cable television industry at the time.[24] The
language was initially called Oak after an oak tree that stood
outside Gosling's office. Later the project went by the name
Green and was finally renamed Java, from Java coffee, the
coffee from Indonesia.[25] Gosling designed Java with a
C/C++-style syntax that system and application programmers
would find familiar.[26]
Sun Microsystems released the first public implementation as
Java 1.0 in 1996.[27] It promised Write Once, Run Anywhere
(WORA) functionality, providing no-cost run-times on popular
platforms. Fairly secure and featuring configurable security,
it allowed network- and file-access restrictions. Major web
browsers soon incorporated the ability to run Java applets
within web pages, and Java quickly became popular. The Java 1.0
compiler was re-written in Java by Arthur van Hoff to comply
strictly with the Java 1.0 language specification.[28] With the
advent of Java 2 (released initially as J2SE 1.2 in December
1998 - 1999), new versions had multiple configurations built
for different types of platforms. J2EE included technologies
and APIs for enterprise applications typically run in server
environments, while J2ME featured APIs optimized for mobile
applications. The desktop version was renamed J2SE. In 2006,
for marketing purposes, Sun renamed new J2 versions as Java EE,
Java ME, and Java SE, respectively.
Trending now
This is a popular solution!
Step by step
Solved in 4 steps with 2 images