nextLine
and a header value) from the file strings.text
,
and prints out various properties and manipulations of the individual strings. The program should also sort the strings and
print them out in sorted order. (This exercise is similar to Lab 14)
As each string is read in, you should print out:
Sample Test Run
For example if the file strings.text
contains:
8 The quick brown fix jumped over the lazy brown dog. Hello world! CISC 1115 is and introduction to Java just... some ... words madam im adam madamimadamthe program should produce the following output:
original string: The quick brown fix jumped over the lazy brown dog. reversed : .god nworb yzal eht revo depmuj xif nworb kciuq ehT vowels removed : Th qck brwn fx jmpd vr th lzy brwn dg. plural : The quick brown fix jumped over the lazy brown dog.s isCapitalized : true containsBlanks : true original string: Hello world! reversed : !dlrow olleH vowels removed : Hll wrld! plural : Hello world!s isCapitalized : true containsBlanks : true original string: CISC 1115 is and introduction to Java reversed : avaJ ot noitcudortni dna si 5111 CSIC vowels removed : CSC 1115 s nd ntrdctn t Jv plural : CISC 1115 is and introduction to Javas isCapitalized : true containsBlanks : true original string: just... reversed : ...tsuj vowels removed : jst... plural : just...s isCapitalized : false containsBlanks : false original string: some ... reversed : ... emos vowels removed : sm ... plural : some ...s isCapitalized : false containsBlanks : true original string: words reversed : sdrow vowels removed : wrds plural : wordses isCapitalized : false containsBlanks : false original string: madam im adam reversed : mada mi madam vowels removed : mdm m dm plural : madam im adams isCapitalized : false containsBlanks : true original string: madamimadam reversed : madamimadam vowels removed : mdmmdm plural : madamimadams isCapitalized : false containsBlanks : false Initial array: { The quick brown fix jumped over the lazy brown dog. Hello world! CISC 1115 is and introduction to Java just... some ... words madam im adam madamimadam } Sorted : { CISC 1115 is and introduction to Java Hello world! The quick brown fix jumped over the lazy brown dog. just... madam im adam madamimadam some ... words }Notes:
String reverse(String s)
, boolean hasBlank(string s)
isVowel
method to make your vowel-removing method cleaner
compareTo
method instead of >, or <.
nextLine
to position the scanner to the next line
for reading the first string of the sequence. (This is the Scanner bug discussed in the text in section 3.10.
nextLine
) from the file black_book.text
.
The first line consists of a name; the second line the phone numbers associated with that name. The program prints out the name followed by
the area codes of all the numbers listed for that name.
Sample Test Run
For example if the file black_book.text
contains:
Smith, Mary work: (456) 765-0987 iPhone: (456) 321-9812 home: (876) 123-4567 Jones, Dave (345) 567-7564the program should produce the following output:
Smith, Mary: 456 456 876 Jones, Dave: 345Notes:
indexOf
), and then print out the next three characters (using substring
)
void find(String line)
which you call from main