This assignment is a pure String problem. Given a string, find the longest run of consonants, case insensitive and which may or may not be consecutive, that are either ascending or descending. In this problem the letter Y is a consonant. The following consonants are ascending - b g t. The following consonants are descending m h c . Repeated consonants can be considered ascending when determining ascending runs and descending when considering descending runs. A string of a single consonant can be considered either ascending or descending.
For example, in the string A human must turn information into intelligence or knowledge. the consonants are h m n m s t t r n n f r m t n n t n t l l g n c r k n w l d g Excluding shorter substrings, the ascending runs are hmn, mstt, r, nn, fr, mt, nnt, nt, ll, gn, cr, knw, dg and the descending runs are nm, ttrnnf, rm, tnn, tn, tllg, nc, rk, wld, g
The string ttrnnf is the longest ascending or descending string, thus the longest run is 6.
You will read from a file called consonant.txt. The first line of input will consist of a single integer, n, indicating the number of lines to follow. Each line will consist of a string between 1 and 128 characters long, inclusive. The string may be a mix of uppercase and lowercase letters, digits, punctuation marks, and spaces.
For each input string, print a single integer on its own line representing the count of the longest run of ascending or descending consonants in the string.
1 ≤ n ≤ 100
3 A human must turn information into intelligence or knowledge. $234.56 QWERTY
6 0 3
The file that you will be submitting will be called Consonant.java. You will choose a data structure that will be appropriate to solve this problem. You will follow the standard Java coding convention that I have appended below. The file will have a header of the following form:
/* File: Consonant.java Description: Student Name: Student UT EID: Partner Name: Partner UT EID: Course Name: CS 312 Unique Number: Date Created: Date Last Modified: */
There is a modification that I would like to make to the standard coding conventions. Please align the opening and closing braces vertically so that you can easily make out the blocks of code. For example:
Do this: if ( x > 5 ) { a = b + c; } Not this: if ( x > 5 ) { a = b + c; }
Use the Canvas program to submit your Consonant.java file. We should receive your work by 11 PM on Wednesday, 29 Jul 2015. There will be substantial penalties if you do not adhere to the guidelines.