Solution Manual for Java How to Program, Early Objects (11th Edition) (Deitel: How to Program) 11th Edition download
Solution Manual for Java How to Program, Early Objects (11th Edition) (Deitel: How to Program) 11th Edition download
https://testbankmall.com/product/solution-manual-for-java-how-to-
program-early-objects-11th-edition-deitel-how-to-program-11th-
edition/
https://testbankmall.com/product/test-bank-for-java-how-to-program-
early-objects-9th-edition-paul-deitel/
testbankmall.com
https://testbankmall.com/product/solution-manual-for-c-how-to-
program-10th-by-deitel/
testbankmall.com
https://testbankmall.com/product/c-how-to-program-10th-edition-deitel-
solutions-manual/
testbankmall.com
https://testbankmall.com/product/managerial-accounting-an-
introduction-to-concepts-methods-and-uses-maher-11th-edition-test-
bank/
testbankmall.com
Test Bank for Financial Accounting: A Business Process
Approach, 3rd Edition: Jane L. Reimers
https://testbankmall.com/product/test-bank-for-financial-accounting-a-
business-process-approach-3rd-edition-jane-l-reimers/
testbankmall.com
https://testbankmall.com/product/test-bank-for-concise-history-of-
western-music-5th-edition-anthology-update-by-barbara-russano-hanning/
testbankmall.com
https://testbankmall.com/product/health-economics-6th-edition-
santerre-test-bank/
testbankmall.com
https://testbankmall.com/product/construction-jobsite-management-4th-
edition-mincks-test-bank/
testbankmall.com
https://testbankmall.com/product/test-bank-for-macroeconomics-fifth-
canadian-edition-5-e-5th-edition-olivier-blanchard-david-w-johnson/
testbankmall.com
Test Bank for Gardners Art through the Ages The Western
Perspective, Volume I, 13th Edition
https://testbankmall.com/product/test-bank-for-gardners-art-through-
the-ages-the-western-perspective-volume-i-13th-edition/
testbankmall.com
■ Use arithmetic operators.
■ Learn the precedence of
arithmetic operators.
■ Write decision-making
statements.
■ Use relational and equality
operators.
jhtp_02_IntroToApplications.FM Page 2 Sunday, May 18, 2014 9:41 PM
Self-Review Exercises 2
Self-Review Exercises
2.1 Fill in the blanks in each of the following statements:
a) A(n) begins the body of every method, and a(n) ends the body of
every method.
ANS: left brace ({), right brace (} ).
b) You can use the statement to make decisions.
ANS: if.
c) begins an end-of-line comment.
ANS: //.
d) , and are called white space.
ANS: Space characters, newlines and tabs.
e) are reserved for use by Java.
ANS: Keywords.
f) Java applications begin execution at method .
ANS: main.
g) Methods , and display information in a command win-
dow.
ANS: System.out.print, System.out.println and System.out.printf.
2.2 State whether each of the following is true or false. If false, explain why.
a) Comments cause the computer to print the text after the // on the screen when the pro-
gram executes.
ANS: False. Comments do not cause any action to be performed when the program exe-
cutes. They’re used to document programs and improve their readability.
b) All variables must be given a type when they’re declared.
ANS: True.
c) Java considers the variables number and NuMbEr to be identical.
ANS: False. Java is case sensitive, so these variables are distinct.
d) The remainder operator (%) can be used only with integer operands.
ANS: False. The remainder operator can also be used with noninteger operands in Java.
e) The arithmetic operators *, /, %, + and - all have the same level of precedence.
ANS: False. The operators *, / and % are higher precedence than operators + and -.
2.3 Write statements to accomplish each of the following tasks:
a) Declare variables c, thisIsAVariable, q76354 and number to be of type int.
ANS: int c, thisIsAVariable, q76354, number;
or
int c;
int thisIsAVariable;
int q76354;
int number;
b) Prompt the user to enter an integer.
ANS: System.out.print("Enter an integer: ");
c) Input an integer and assign the result to int variable value. Assume Scanner variable
input can be used to read a value from the keyboard.
ANS: value = input.nextInt();
d) Print "This is a Java program" on one line in the command window. Use method
System.out.println.
ANS: System.out.println("This is a Java program");
jhtp_02_IntroToApplications.FM Page 3 Sunday, May 18, 2014 9:41 PM
e) Print "This is a Java program" on two lines in the command window. The first line
should end with Java. Use method System.out.printf and two %s format specifiers.
ANS: System.out.printf("%s%n%s%n", "This is a Java", "program");
f) If the variable number is not equal to 7, display "The variable number is not equal to 7".
ANS: if (number != 7)
System.out.println("The variable number is not equal to 7");
2.4 Identify and correct the errors in each of the following statements:
a) if (c < 7);
System.out.println("c is less than 7");
ANS: Error: Semicolon after the right parenthesis of the condition (c < 7) in the if.
Correction: Remove the semicolon after the right parenthesis. [Note: As a result, the
output statement will execute regardless of whether the condition in the if is true.]
b) if (c => 7)
System.out.println("c is equal to or greater than 7");
ANS: Error: The relational operator => is incorrect. Correction: Change => to >=.
2.5 Write declarations, statements or comments that accomplish each of the following tasks:
a) State that a program will calculate the product of three integers.
ANS: // Calculate the product of three integers
b) Create a Scanner called input that reads values from the standard input.
ANS: Scanner input = new Scanner(System.in);
c) Declare the variables x, y, z and result to be of type int.
ANS: int x, y, z, result;
or
int x;
int y;
int z;
int result;
d) Prompt the user to enter the first integer.
ANS: System.out.print("Enter first integer: ");
e) Read the first integer from the user and store it in the variable x.
ANS: x = input.nextInt();
f) Prompt the user to enter the second integer.
ANS: System.out.print("Enter second integer: ");
g) Read the second integer from the user and store it in the variable y.
ANS: y = input.nextInt();
h) Prompt the user to enter the third integer.
ANS: System.out.print("Enter third integer: ");
i) Read the third integer from the user and store it in the variable z.
ANS: z = input.nextInt();
j) Compute the product of the three integers contained in variables x, y and z, and assign
the result to the variable result.
ANS: result = x * y * z;
k) Use System.out.printf to display the message "Product is" followed by the value of
the variable result.
ANS: System.out.printf("Product is %d%n", result);
jhtp_02_IntroToApplications.FM Page 4 Sunday, May 18, 2014 9:41 PM
Exercises 4
2.6 Using the statements you wrote in Exercise 2.5, write a complete program that calculates
and prints the product of three integers.
ANS:
Exercises
NOTE: Solutions to the programming exercises are located in the ch02solutions folder.
Each exercise has its own folder named ex02_## where ## is a two-digit number represent-
ing the exercise number. For example, exercise 2.14’s solution is located in the folder
ex02_14.
2.7 Fill in the blanks in each of the following statements:
a) are used to document a program and improve its readability.
ANS: Comments.
b) A decision can be made in a Java program with a(n) .
ANS: if statement.
c) Calculations are normally performed by statements.
ANS: assignment statements.
d) The arithmetic operators with the same precedence as multiplication are and
.
jhtp_02_IntroToApplications.FM Page 5 Sunday, May 18, 2014 9:41 PM
Exercises 6
a) x = 7 + 3 * 6 / 2 - 1;
ANS: *, /, +, -; Value of x is 15.
b) x = 2 % 2 + 2 * 2 - 2 / 2;
ANS: %, *, /, +, -; Value of x is 3.
c) x = (3 * 9 * (3 + (9 * 3 / (3))));
ANS: x = ( 3 * 9 * ( 3 + ( 9 * 3 / ( 3 ) ) ) );
4 5 3 1 2
Value of x is 324.
2.19 What does the following code print?
System.out.printf("*%n**%n***%n****%n*****%n");
ANS:
*
**
***
****
*****
ANS:
*
***
*****
****
**
ANS:
***************
System.out.println("*****");
System.out.print("****");
System.out.println("**");
ANS:
****
*****
******
ANS:
*
***
*****
Other documents randomly have
different content
frightened voice crying out, “Monsieur, you are wanted; you are
wanted.” He sprang from table, saw the smoke rolling in volumes
from the top of the rock, ran up the steep ascent, reached the
seminary, and found an excited crowd making a prodigious outcry.
He shouted for carpenters. Four men came to him, and he set them
at work with such tools as they had to tear away planks and beams,
and prevent the fire from spreading to the adjacent parts of the
building; but, when he went to find others to help them, they ran
off. He set new men in their place, and these too ran off the moment
his back was turned. A cry was raised that the building was to be
blown up, on which the crowd scattered for their lives. Vasseur now
gave up the seminary for lost, and thought only of cutting off the fire
from the rear of the church, which was not far distant. In this he
succeeded, by tearing down an intervening wing or gallery. The walls
of the burning building were of massive stone, and by seven o’clock
the fire had spent itself. We hear nothing of the Dutch pump, nor
does it appear that the soldiers of the garrison made any effort to
keep order. Under cover of the confusion, property was stolen from
the seminary to the amount of about two thousand livres, which is
remarkable, considering the religious character of the building, and
the supposed piety of the people. “There were more than three
hundred persons at the fire," says Yasseur; “but thirty picked men
would have been worth more than the whole of them.” *
August, September, and October were the busy months at
Quebec. Then the ships from France discharged their lading, the
shops and warehouses of the Lower Town were filled with goods,
and the habitants came to town to make their purchases. When the
frosts began, the vessels sailed away, the harbor was deserted, the
streets were silent again, and like ants or squirrels the people set at
work to lay in their winter stores. Fathers of families packed their
cellars with beets, carrots, potatoes, and cabbages; and, at the end
of autumn, with meat, fowls, game, fish, and eels, all frozen to stony
hardness. Most of the shops closed, and the long season of leisure
and amusement began. New Year’s day brought visits and mutual
gifts. Thence till Lent dinner parties were frequent, sometimes
familiar and sometimes ceremonious. The governor’s little court at
the chateau was a standing example to all the aspiring spirits of
Quebec, and forms and orders of precedence were in some houses
punctiliously observed. There were dinners to the military and civic
dignitaries and their wives, and others, quite distinct, to prominent
citizens. The wives and daughters of the burghers of Quebec are
said to have been superior in manners to women of the
corresponding
** Mémoire de 1736.
amuses himself with hoarding it. They say it is very different with
our neighbors the English, and one who knew the two colonies only
by the way of living, acting, and speaking of the colonists would not
hesitate to judge ours the more flourishing. In New England and the
other British colonies, there reigns an opulence by which the people
seem not to know how to profit; while in New France poverty is
hidden under an air of ease which appears entirely natural. The
English colonist keeps as much and spends as little as possible: the
French colonist enjoys what he has got, and often makes a display
of what he has not got. The one labors for his heirs: the other leaves
them to get on as they can, like himself. I could push the
comparison farther; but I must close here: the king’s ship is about to
sail, and the merchant vessels are getting ready to follow. In three
days perhaps, not one will be left in the harbor.” * And now we, too,
will leave Canada. Winter draws near, and the first patch of snow lies
gleaming on the distant mountain of Cape Tourmente. The sun has
set in chill autumnal beauty, and the sharp spires of fir-trees on the
heights of Sillery stand stiff and black against the pure cold amber of
the fading west. The ship sails in the morning; and, before the old
towers of Rochelle rise in sight, there will be time to smoke many a
pipe, and ponder what we have seen on the banks of the St
Lawrence.
N
ot institutions alone, but geographical position, climate, and
many other conditions unite to form the educational
influences that, acting through successive generations, shape
the character of nations and communities.
It is easy to see the nature of the education, past and present,
which wrought on the Canadians and made them what they were.
An ignorant population, sprung from a brave and active race, but
trained to subjection and dependence through centuries of feudal
and monarchical despotism, was planted in the wilderness by the
hand of authority, and told to grow and flourish. Artificial stimulants
were applied, but freedom was withheld. Perpetual intervention of
government, regulations, restrictions, encouragements sometimes
more mischievous than restrictions, a constant uncertainty what the
authorities would do next, the fate of each man resting less with
himself than with another, volition enfeebled, self-reliance paralyzed,
—the condition, in short, of a child held always under the rule of a
father, in the main well-meaning and kind, sometimes generous,
sometimes neglectful, often capricious, and rarely very wise,—such
were the influences under which Canada grew up. If she had
prospered, it would have been sheer miracle. A man, to be a man,
must feel that he holds his fate, in some good measure, in his own
hands.
But this was not all. Against absolute authority there was a
counter influence, rudely and wildly antagonistic. Canada was at the
very portal of the great interior wilderness. The St. Lawrence and
the Lakes were the highway to that domain of savage freedom; and
thither the disfranchised, half-starved seignior, and the discouraged
habitant who could find no market for his produce, naturally enough
betook themselves. Their lesson of savagery was well learned, and
for many a year a boundless license and a stiff-handed authority
battled for the control of Canada. Nor, to the last, were church and
state fairly masters of the field. The French rule was drawing
towards its close when the intendant complained that though
twenty-eight companies of regular troops were quartered in the
colony, there were not soldiers enough to keep the people in order. *
One cannot but remember that in a neighboring colony, far more
populous, perfect order prevailed, with no other
Updated editions will replace the previous one—the old editions will
be renamed.
1.D. The copyright laws of the place where you are located also
govern what you can do with this work. Copyright laws in most
countries are in a constant state of change. If you are outside the
United States, check the laws of your country in addition to the
terms of this agreement before downloading, copying, displaying,
performing, distributing or creating derivative works based on this
work or any other Project Gutenberg™ work. The Foundation makes
no representations concerning the copyright status of any work in
any country other than the United States.
1.E.6. You may convert to and distribute this work in any binary,
compressed, marked up, nonproprietary or proprietary form,
including any word processing or hypertext form. However, if you
provide access to or distribute copies of a Project Gutenberg™ work
in a format other than “Plain Vanilla ASCII” or other format used in
the official version posted on the official Project Gutenberg™ website
(www.gutenberg.org), you must, at no additional cost, fee or
expense to the user, provide a copy, a means of exporting a copy, or
a means of obtaining a copy upon request, of the work in its original
“Plain Vanilla ASCII” or other form. Any alternate format must
include the full Project Gutenberg™ License as specified in
paragraph 1.E.1.
• You pay a royalty fee of 20% of the gross profits you derive
from the use of Project Gutenberg™ works calculated using the
method you already use to calculate your applicable taxes. The
fee is owed to the owner of the Project Gutenberg™ trademark,
but he has agreed to donate royalties under this paragraph to
the Project Gutenberg Literary Archive Foundation. Royalty
payments must be paid within 60 days following each date on
which you prepare (or are legally required to prepare) your
periodic tax returns. Royalty payments should be clearly marked
as such and sent to the Project Gutenberg Literary Archive
Foundation at the address specified in Section 4, “Information
about donations to the Project Gutenberg Literary Archive
Foundation.”
• You comply with all other terms of this agreement for free
distribution of Project Gutenberg™ works.
1.F.
1.F.4. Except for the limited right of replacement or refund set forth
in paragraph 1.F.3, this work is provided to you ‘AS-IS’, WITH NO
OTHER WARRANTIES OF ANY KIND, EXPRESS OR IMPLIED,
INCLUDING BUT NOT LIMITED TO WARRANTIES OF
MERCHANTABILITY OR FITNESS FOR ANY PURPOSE.
Please check the Project Gutenberg web pages for current donation
methods and addresses. Donations are accepted in a number of
other ways including checks, online payments and credit card
donations. To donate, please visit: www.gutenberg.org/donate.
Most people start at our website which has the main PG search
facility: www.gutenberg.org.