You are on page 1of 27

Starting Out with Java From Control

Structures through Data Structures 3rd


Edition Gaddis Solutions Manual
Visit to download the full and correct content document: https://testbankdeal.com/dow
nload/starting-out-with-java-from-control-structures-through-data-structures-3rd-editio
n-gaddis-solutions-manual/
Gaddis: Starting Out with Java: From Control Structures through Data Structures, 3/e 1

Starting Out with Java - From Control Structures through Data Structures
Answers to Review Questions

Chapter 9

Multiple Choice and True/False

1. c
2. b
3. a
4. a
5. a
6. c
7. b
8. a
9. d
10. b
11. a
12. c
13. d
14. a
15. False
16. True
17. False
18. True
19. True
20. False
21. True
22. False
23. False

Find the Error

1. The valueOf method is static. It should be called like this:


str = String.valueOf(number);
2. You cannot initialize a StringBuilder object with the = operator. You must
pass the string as an argument to the constructor, such as:
StringBuilder name = new StringBuilder("Joe Schmoe");
3. The very first character is at position 0, so the statement should read:
str.setCharAt(0, 'Z');
4. The tokens variable should reference the array of tokens returned by the
str.split method, so the statement should read:
String[] tokens = str.split(";")
You cannot print the tokens to the screen by simply passing the tokens variable
as an argument to System.out.println. If the tokens are to be printed to the

Copyright © 2016 Pearson Education, Inc., Hoboken NJ


Gaddis: Starting Out with Java: From Control Structures through Data Structures, 3/e 2

screen, a loop should be used to process each element in the array, so the
statement should read:
for (String s : tokens)
System.out.println(s)

Algorithm Workbench

1. if (Character.toUpperCase(choice) == 'Y')

Or

if (Character.toLowerCase(choice) == 'y')

2. int total = 0;
for (int i = 0; i < str.length(); i++)
{
if (str.charAt(i) == ' ')
total++;
}

3. int total = 0;
for (int i = 0; i < str.length(); i++)
{
if (Character.isDigit(str.charAt(i)))
total++;
}

4. int total = 0;
for (int i = 0; i < str.length(); i++)
{
if (Character.isLowerCase(str.charAt(i)))
total++;
}

5. public static boolean dotCom(String str)


{
boolean status;
if (str.endsWith(".com"))
status = true;
else
status = false;
return status;
}

Copyright © 2016 Pearson Education, Inc., Hoboken NJ


Gaddis: Starting Out with Java: From Control Structures through Data Structures, 3/e 3

6. public static boolean dotCom(String str)


{
boolean status;
String str2 = str.toLowerCase();

if (str2.endsWith(".com"))
status = true;
else
status = false;
return status;
}

7. public static void upperT(StringBuilder str)


{
for (int i = 0; i < str.length(); i++)
{
if (str.charAt(i) == 't')
str.setCharAt(i, 'T');
}
}

8. String str = "cookies>milk>fudge:cake:ice cream";


String[] tokens = str.split("[>:]");
for (int i = 0; i < (tokens.length - 1); i++)
{
System.out.printf("%s, ", tokens[i]);
}
System.out.printf("and %s\n",
tokens[tokens.length - 1]);

9. if (d <= Integer.MAX_VALUE)
i = (int) d;

10. System.out.println(Integer.toBinaryString(i));
System.out.println(Integer.toHexString(i));
System.out.println(Integer.toOctalString(i));

Short Answer

1. This will improve the program’s efficiency by reducing the number of String
objects that must be created and then removed by the garbage collector.
2. When you are tokenizing a string that was entered by the user, and you are using
characters other than whitespaces as delimiters, you will probably want to trim the
string before tokenizing it. Otherwise, if the user enters leading whitespace

Copyright © 2016 Pearson Education, Inc., Hoboken NJ


Gaddis: Starting Out with Java: From Control Structures through Data Structures, 3/e 4

characters, they will become part of the first token. Likewise, if the user enters
trailing whitespace characters, they will become part of the last token.
3. Converts a number to a string.
4. Each of the numeric wrapper classes has final static fields named MAX_VALUE
and MIN_VALUE. These fields hold the maximum and minimum values for the
data type.

Copyright © 2016 Pearson Education, Inc., Hoboken NJ


Another random document with
no related content on Scribd:
[111]

The term natural is here employed in the empirical sense


described by Brunner von Wattenwyl, Nouv. Syst. Blattaires, 1865,
p. vii.

[112]

Lord Walsingham, Proc. Ent. Soc. London, 1889, p. lxxx.

[113]

We may mention that fossil Insects are chiefly determined from


their wing-remains, which are often surprisingly perfect. This is one
of the reasons that have induced us to prefer a classification of
Insects in which the nature of the wings is considered of great
value. It would be impossible to refer fossil Insects to groups that
are established on account of the metamorphosis or of the internal
structure of their components, for there is not yet any evidence on
either of these points in the fossil remains preserved for us by the
rocks.

[114]

Bull. U.S. Geol. Survey, No. 31, 1886, p. 109.

[115]

Mem. Acc. Lincei Roma (4), iv. 1888, p. 543, etc., and other
preceding memoirs mentioned therein.

[116]

Bijdr. Dierkunde, xvi. 1888, pp. 147-227.

[117]

Natural. Sicil., ix. 1889, pp. 25, etc.

[118]

Ann. Soc. ent. France, 1892, p. 34.


[119]

Morph. Jahrb. xv. 1889, p. 363.

[120]

SB. Ak. Wien, c. 1891, Abth. I. p. 216.

[121]

Ent. Tidskr. i. 1880, p. 159.

[122]

Morphol. Jahrb. xv. 1888, p. 361.

[123]

Verh. zool.-bot. Ges. Wien, viii. 1858, p. 564.

[124]

Ann. Soc. ent. France, 4th ser. iv. 1864, p. 705.

[125]

Rev. biol. Nord France, ii. 1890, p. 347.

[126]

J. Morphol. viii. 1893, p. 64.

[127]

Ent. Mo. Mag. xxv. 1889, and xxvi. 1890.

[128]

Ann. Mus. Genova, xxxiii. (1892).

[129]

Orthoptera Europaea, 1853, pl. vi. f. 4, p. 434.


[130]

Morph. Bedeut. Seg. Orthopt. 1876, p. 14; and Prod. Orthopt.


Europ. 1882, p. 3.

[131]

Proc. Zool. Soc. London, 1892, p. 586.

[132]

Naturhistorisk Tidsskrift, 3rd ser. ii. 1863, p. 475.

[133]

Arch. mikr. Anat. xxxvi. 1890, p. 565.

[134]

Ann. Sci. Nat. xiii. 1828, p. 337.

[135]

Naturhistorisk Tidsskrift, 3rd ser. ii. 1863, p. 475.

[136]

Some writers are of opinion that there are only two thoracic
spiracles in Insects, considering the third as belonging really to the
abdomen. Looking on the point as at present chiefly one of
nomenclature, we make use of the more usual mode of
expression.

[137]

As on last page, and also op. cit. v. 1868, p. 278.

[138]

Bull. Ent. Ital. xii. 1880, p. 46.

[139]
It may be worth while to repeat that "joint" means a piece, and is
the equivalent of "link" in a chain.

[140]

Materials for the Study of Variation, 1894, p. 413.

[141]

Naturhist. Tidsskrift, 3rd ser. ii. 1863, p. 474.

[142]

Mt. Schweiz. ent. Ges. vii. 1887, p. 310.

[143]

Mem. hist. Insectes, iii. 1773, p. 548.

[144]

SB. Ges. naturf. Fr. Berlin, 1893, p. 127.

[145]

Ent. Tidskr. 1894, p. 65.

[146]

This enigmatic structure is similar in position to the aural orifice of


Locustidae (see Fig. 101); but it is closed by a transparent
membrane, whereas the ear orifice of Locustidae is, as we shall
subsequently see, quite open.

[147]

Rev. biol. Nord France, vii. 1894, p. 111.

[148]

Ann. Nat. Hist. Decr. 6th, ser. x. 1892, p. 433.

[149]
Prod. Orth. europ. 1882, p. 27, and Rev. Syst. Orthopt. 1892, p.
15. Unfortunately de Saussure adopts a different nomenclature;
we have preferred Brunner's as being more simple.

[150]

Ann. Sci. Nat. Zool. ser. 5, x. 1868, p. 161.

[151]

Nouv. Syst. Blattaires, 1865, p. 265.

[152]

The Cockroach, p. 170.

[153]

Cf. Duchamp, Rev. Sci. Nat. Montpellier, vii. [?1879], p. 423.

[154]

Huxley, Manual Anat. Invert. Animals, 1877, p. 416.

[155]

Riley, Insect Life, iii. 1891, p. 443, and iv. 1891, p. 119.

[156]

Essais entomologiques, St. Petersburg, 1821.

[157]

Beiträge zur näheren Kenntniss von Periplaneta orientalis,


Elberfeld, 1853.

[158]

Nouv. Syst. Blattares, 1865, p. 16, etc.

[159]

Naturalist in Nicaragua, 1874, p. 110.


[160]

See Bolivar, Ann. Soc. ent. France, 1892, p. 29.

[161]

P. ent. Soc. London, 1881, p. 1.

[162]

Biol. Centr. Amer. Orthopt. 1893, p. 57.

[163]

Schäff, Zool. Anz. xvi. 1893, p. 17.

[164]

Westwood, Modern Class. Insects, i. 1839, p. 418.

[165]

Zeitschr. wiss. Zool. xlviii. 1889, p. 89; and Mem. Ac. St. Petersb.
xxxviii. No. 5, 1891.

[166]

Ann. Hofmus. Wien., i. 1886, p. 104.

[167]

Zittel, Handb. Palaeont. I Abth. ii. 1885, p. 753.

[168]

Biol. Centr.-Amer. Orthoptera, 1893.

[169]

Although the genus Chorisoneura has unarmed femora, it must be


placed in this division.

[170]
The "black beetle," Stilopyga orientalis, belongs to this tribe, as
does also Periplaneta americana.

[171]

Tr. R. Soc. S. Austral. xvii. 1893, p. 68.

[172]

Zeitschr. wiss. Zool. xxx. 1878, p. 609, pl. xxxviii. fig. 7.

[173]

Arch. f. Naturgesch. xxx. Band 1, 1864, p. 7.

[174]

Biol. Centr. Amer. Orthopt. 1894, p. 160.

[175]

Our figures do not exhibit this attitude; if portrayed in their natural


position in a drawing the front legs would be to a large extent
obscured.

[176]

The name of the species is not given (Tr. N. Z. Inst. xvi. 1883, p.
114), but it is probably Orthodera ministralis Fab., an Australian
Insect perhaps taken to New Zealand by miners. Cf. Wood-Mason,
Cat. Mantodea, i. 1889, p. 20.

[177]

Berlin. ent. Zeitschr. viii. 1864, p. 234.

[178]

Ann. Soc. Linn. Lyon, xi. 1893, p. 205.

[179]

Proc. ent. Soc. London, 1867, p. cv.


[180]

Cat. Mantodea, i. 1889, p. 4.

[181]

Ann. Soc. ent. France, 1835, p. 457.

[182]

P. ent. Soc. London, 1877, p. xxix.

[183]

Afbeeldingen der Spoken en wandelende Bladen, etc.,


Amsterdam, 1813.

[184]

P. Asiat. Soc. Bengal, 1877, p. 193.

[185]

Tr. ent. Soc. London, 1878, p. 263.

[186]

Ann. Nat. Hist. 3rd ser. xix. 1867, p. 144.

[187]

Bull. Soc. Philomat. (8) ii. 1890, p. 154.

[188]

Insectes fossiles des temps primaires, 1894, p. 353.

[189]

Acta Ac. German. xii. 1825, pp. 555-672, pls. l.-liv.

[190]

Mem. Ac. Sci. Toulouse, series 7, iii. pp. 1-30.


[191]

Edinburgh Philosoph. Journ. January 1856.

[192]

Zool. Jahrb. Syst. i. 1886, p. 724.

[193]

P. Boston Soc. xii. 1869, p. 99.

[194]

Prod. Zool. Victoria, Decade vii. 1882, p. 34.

[195]

See de Borre, CR. Soc. ent. Belgique, xxvii. 1883, p. cxliii.

[196]

See Murray, Edinburgh New Philosophical Journal, January 1856.

[197]

CR. Ac. Paris, cxviii. 1894, No. 24, p. 1299.

[198]

SB. Ak. Wien, xci. 1885, p. 361. The nomenclature applied to the
nervures by these authors is not the same as that of Brunner;
according to their view the wing of Phyllium, female, differs more
from the wing of Blatta than it does according to a comparison
made with the nomenclature we adopt.

[199]

Bull. Soc. Philomathique (8), ii. p. 18.

[200]

Laboulbène, Bull. Soc. ent. France, 1857, p. cxxxvi., and


Henneguy as above.
[201]

Ann. Nat. Hist. (5) i. 1878, p. 101.

[202]

The antennae in the specimen represented were no doubt


mutilated, though Westwood did not say so.

[203]

CR. Ac. Paris, xcviii. 1884, p. 832.

[204]

In his recent Insectes fossiles des temps primaires, pp. 373 and
396, M. Brongniart has himself removed this Insect to
Protodonates. We shall again mention it when discussing that
group.

[205]

Bactridium, though placed in this tribe, has only short antennae, of


20 joints.

[206]

Bostra and Clonistria, belonging to Bacunculides, have the median


segment almost as long as the metanotum.

[207]

The American genera Pterinoxylus, Haplopus, and Candaules, as


well as the African Palophus, possess winged females.

[208]

The African and Australian genera Orobia and Paraorobia,


although they have a short median segment, are placed in the
tribe Phasmides of this division.

[209]
This character is evidently erroneous as regards the males of the
genus Phyllium.—D. S.

[210]

Ann. Hofmus. Wien, i. 1886, p. 175.

[211]

Newport, Tr. Linn. Soc. xx. 1851, p. 419.

[212]

Mem. Ac. Sci. Étrang. vii. 1834, p. 274.

[213]

First Ann. Rep. U.S. Ent. Comm. 1878, p. 271.

[214]

Rep. U.S. Ent. Comm. ii. 1880, p. 223.

[215]

Ann. Sci. Nat. (7) iv. Zool. 1887.

[216]

Verh. zool-bot. Ges. Wien, xxi. 1871, p. 1097.

[217]

Verh. zool.-bot. Ges. Wien, xxiv. 1874, p. 286.

[218]

Denk. Ak. Wien, xxxvi. 1875; Arch. mikr. Anat. xx. and xxi., 1882.

[219]

Mem. Ac. Sci. Étrang. vii. 1834, p. 306.


[220]

Bull. Soc. Philomath. (8) v. 1893, p. 5.

[221]

First Ann. Rep. U.S. Ent. Comm. 1878, p. 279.

[222]

Rep. Ins. Missouri, ix. 1877, p. 86.

[223]

Bull. Soc. ent. France (6), x. 1890, p. xxxvii., and CR. Ac. Paris,
ex. 1890, p. 657.

[224]

Carruthers in Nature, xli. 1889, p. 153.

[225]

Blue-book, C, 4960, 1887; and P. ent. Soc. London, 1881, p.


xxxviii.

[226]

Rep. Entomologist, 1885, p. 229.

[227]

Tr. S. Afr. Phil. Soc. i. 1880, p. 193. The species is thought to be


Pachytylus sulcicollis Stål.

[228]

CR. Soc. ent. Belgique, xxi. 1878, p. 5.

[229]

Addit. ad Prodromum Oedipodiorum, 1888, p. 12.

[230]
See Redtenbacher, Über Wanderheuschrecken, in Jahresber.
Realschule Budweis, 1893.

[231]

J. Bombay N. H. Soc. viii. 1893, p. 120.

[232]

P. ent. Soc. London, 1893, p. xxi.

[233]

Rep. injurious Insects, xvii. 1893, p. 47.

[234]

Ent. Nachricht. viii. 1882, p. 160.

[235]

Monograph by Bolivar, Ann. Soc. Esp. xiii. 1884, p. 1, etc.

[236]

Monograph, de Saussure, Spicilegia entomologica Genavensia, pt.


2, Geneva, 1887.

[237]

Monograph, de Saussure, Mem. Soc. Phys. Genève, xxviii. 1884,


No. 9; and xxx. 1888, No. 1.

[238]

Prod. Eur. Orthopt. 1882, p. 160.

[239]

Science, xxi. p. 133.

[240]

An. Soc. Espan. xv. 1886, p. 273.


[241]

Nature, iv. 1871, p. 333.

[242]

Bull. Soc. Rouen, 1885, and Insectes fossiles, etc. 1894, p. 439.

[243]

A few species of Proscopiides and Oedipodides, though placed in


the next division, are destitute of any claw-pad.

[244]

This applies specially to the males.—D. S.

[245]

Ann. Rep. Insects Missouri, vi. 1874, p. 155.

[246]

Zeitschr. wiss. Zool. xxv. 1875, pp. 174-200, pl. xii.

[247]

Arch. f. mikr. Anat. xx. 1882, and xxi. See also von Adelung,
Zeitschr. wiss. Zool. liv. 1892, p. 316.

[248]

The small space above lm left free from dots is, we presume, due
to an omission on the part of Graber's artist, but we have not
thought it right to interfere with his diagram.

[249]

Ann. Rep. Insects Missouri, vi. 1874, p. 159.

[250]

Wheeler, J. Morphol. viii. 1893.


[251]

Verh. zool.-bot. Ges. Wien, xxxiii. 1883, p. 248.

[252]

Bonnet and Finot, Rev. Sci. Nat. (3) iv. p. 345. The word we have
translated as humming is "bruissement."

[253]

De Saussure, Ann. Soc. ent. France, 1888, p. 151, pl. v. fig. 1.

[254]

Indian Mus. Notes, ii. 1893, p. 172.

[255]

Zoologist, 1867, p. 489.

[256]

This diagnosis is an attempt to express in something approaching


an exact manner the distinction of the flattened from the arched or
convex head.

[257]

Scrobes are the depressions in which the antennae are inserted.

[258]

There are unfortunately a few exceptions in the case of this


character.

[259]

See Pungur, Termes. Füzetek, 1877, p. 223.

[260]

Brunner, Verh. zool.-bot. Ges. Wien, xxiv. 1874, p. 288.


[261]

Natural History of Selborne, Letter xc.

[262]

Müller's Arch. 1859, p. 159.

[263]

Bull. Soc. ent. France, 1893, p. cccxli.

[264]

Zeitschr. wiss. Zool. xxiii. 1876, p. 122.

[265]

Ibid. xli. 1885, p. 570.

[266]

Morph. Jahrb. xv. 1889, p. 400.

[267]

Mem. Soc. phys. Genève, xxv. 1877, and Biol. Centr. Amer.
Orthoptera, 1894, p. 198.

[268]

The genus Myrmecophila, being exceptional in several respects, is


treated separately.

[269]

Insectes fossiles des temps primaires, 1893, vol. i. and atlas.

[270]

Giebel and Nitzsch, Insecta epizoica, folio, 1874.

[271]

Zeitschr. wiss. Zool. xlii. 1885, p. 537.


[272]

Zeitschr. wiss. Zool. xlii. 1885, pl. xviii. f. 15.

[273]

Arch. f. Naturg. xxxv. i. 1869, p. 154, pls. x. xi.

[274]

Op. cit. pp. vii.-xiv. For classification, etc., see also Piaget, Les
Pédiculines. Leyden, 1880.

[275]

Zeitschr. wiss. Zool. xlii. 1885, p. 532.

[276]

P. ent. Soc. London, 1890, p. xxx.

[277]

Bull. Soc. Philom. (7) ix. p. 33.

[278]

P. Zool. Soc. London, 1883, p. 628.

[279]

Ann. Hofmus. Wien, i. 1886, p. 171.

[280]

Atti Acc. Gioenia, vii. 1893.

[281]

J. Linn. Soc. Zool. xiii. 1878, pl. xxi. f. 2.

[282]

Canadian Entomologist, xvii. 1885, throughout.


[283]

Jena. Zeitschr. Naturw. ix. 1875, pl. xii. See also Stokes in
Science, xxii. 1893, p. 273.

[284]

Ann. Hofmus. Wien, i. 1886, p. 183.

[285]

Jena. Zeitschr. Naturw. ix. 1875, p. 257.

[286]

Bidie, in Nature, xxvi. 1882, p. 549.

[287]

Linnaea Entomologica, xii. 1858, p. 305.

[288]

P. Boston Soc. xx. 1878, p. 118.

[289]

Atti Acc. Gioen. vi. and vii. 1893 and 1894.

[290]

Ann. Sci. Nat. Zool. (4) v. 1856, p. 227.

[291]

Ann. Soc. ent. France (5), vi. 1876, p. 201.

[292]

Phil. Trans. lxxi. 1781, pp. 139-192.

[293]

Ann. Nat. Hist. (2) v. 1850, p. 92.


[294]

Dr. G. D. Haviland informs the writer that he thinks it probable this


so-called peristaltic movement is merely the result of alarm; he has
not, however, had any opportunity of observing T. bellicosus.

[295]

Tr. N. York Ac. viii. 1889, pp. 85-114; and ix. 1890, pp. 157-180.

[296]

Camerano, Bull. Soc. ent. Ital. xvii. 1885, p. 89; and Kollmann,
Verh. Ges. Basel, vii. 1883, p. 391.

[297]

Jena. Zeitschr. Naturw. vii. 1873, p. 458.

[298]

CR. Ac. Paris, cxix. 1894, p. 804.

[299]

Congr. internat. Zool. ii. 1892, pt. i. p. 249.

[300]

P. Boston Soc. xi. 1868, p. 399.

[301]

Kolbe, Ent. Nachr. xiii. 1887, p. 70.

[302]

Trans. N. York Ac. viii. 1889, p. 91.

[303]

Congr. internat. Zool. ii. 1892, p. 249.

[304]
P. Boston Soc. xix. 1878, p. 267; and xx. 1881, p. 121.

[305]

According to Melliss, it is thought that the Insect may have been


carried to the island in a captured slave-ship. Melliss, St. Helena,
1875, p. 171.

[306]

In some exotic species there is a dense network on a part of the


anterior wing.

[307]

P. Boston Soc. xix. 1878, p. 292.

[308]

Germar, Mag. Entomol. iv. 1821, p. 276, pl. ii.

[309]

Psyche, iii. 1881, p. 196.

[310]

Kolbe, Stettin, ent. Zeit. xli. 1880, p. 179.

[311]

Op. cit. p. 209, etc.

[312]

Arch. f. Naturg. xlix. i. 1883, p. 99.

[313]

Verh. Ver. Rheinland, xxxix. 1882, Corr.-bl. p. 128.

[314]

Berlin ent. Zeit. xxviii. 1884, p. 36.

You might also like