Skip to content

Commit ca755c6

Browse files
committed
replaced \em with \it in exercises
1 parent ba75bca commit ca755c6

2 files changed

Lines changed: 38 additions & 18 deletions

File tree

em.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
"""Search for \em in exercise (theorem) environments; these will be typeset as
2+
normal font in HTML versions."""
3+
4+
def main():
5+
num = 0
6+
inex = False
7+
for line in open("thinkjava.tex"):
8+
num += 1
9+
if "\\begin{exercise}" in line:
10+
inex = True
11+
continue
12+
if "\\end{exercise}" in line:
13+
inex = False
14+
continue
15+
if inex and "\\em" in line:
16+
print num
17+
print line
18+
19+
if __name__ == "__main__":
20+
main()

thinkjava.tex

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1923,7 +1923,7 @@ \section{Exercises}
19231923
Thursday 16 July 2015
19241924
\end{stdout}
19251925

1926-
%{\em Hint:} You should be able to copy, paste, and modify the code from Step 4 when completing Step 5.
1926+
%{\it Hint:} You should be able to copy, paste, and modify the code from Step 4 when completing Step 5.
19271927
\end{enumerate}
19281928

19291929
\end{exercise}
@@ -1954,7 +1954,7 @@ \section{Exercises}
19541954

19551955
\end{enumerate}
19561956

1957-
{\em Hint:} You might want to use additional variables to hold values during the computation.
1957+
{\it Hint:} You might want to use additional variables to hold values during the computation.
19581958
Variables that are used in a computation but never displayed are sometimes called ``intermediate'' or ``temporary'' variables.
19591959

19601960
\end{exercise}
@@ -2625,7 +2625,7 @@ \section{Exercises}
26252625
It should (1) prompt the user for input, (2) read an integer from the keyboard, (3) calculate the result, and (4) use \java{printf} to display the output.
26262626
For example, {\tt "5000 seconds = 1 hours, 23 minutes, and 20 seconds"}.
26272627

2628-
{\em Hint:} Use the modulus operator.
2628+
{\it Hint:} Use the modulus operator.
26292629
\end{exercise}
26302630

26312631

@@ -3420,7 +3420,7 @@ \section{Exercises}
34203420
\item What is the output of the following program?
34213421
Be precise about where there are spaces and where there are newlines.
34223422

3423-
{\em Hint:} Start by describing in words what \java{ping} and \java{baffle} do when they are invoked.
3423+
{\it Hint:} Start by describing in words what \java{ping} and \java{baffle} do when they are invoked.
34243424

34253425
\item Draw a stack diagram that shows the state of the program the first time \java{ping} is invoked.
34263426

@@ -4155,7 +4155,7 @@ \section{Exercises}
41554155

41564156
\begin{enumerate}
41574157

4158-
\item Draw a stack diagram that shows the state of the program the {\em second} time \java{zoop} is invoked.
4158+
\item Draw a stack diagram that shows the state of the program the {\it second} time \java{zoop} is invoked.
41594159

41604160
\item What is the complete output?
41614161

@@ -4207,7 +4207,7 @@ \section{Exercises}
42074207
If $n$ is greater than 2 and $a^n + b^n = c^n$, the program should display ``Holy smokes, Fermat was wrong!''
42084208
Otherwise the program should display ``No, that doesn't work.''
42094209

4210-
{\em Hint:} You may want to use \java{Math.pow}.
4210+
{\it Hint:} You may want to use \java{Math.pow}.
42114211

42124212
\end{exercise}
42134213

@@ -4297,7 +4297,7 @@ \section{Exercises}
42974297
Adding a small amount of code at a time, and testing as you go, modify the program so it tells the user whether the guess is too high or too low, and then prompts the user for another guess.
42984298

42994299
The program should continue until the user gets it right.
4300-
{\em Hint:} Use two methods, and make one of them recursive.
4300+
{\it Hint:} Use two methods, and make one of them recursive.
43014301

43024302
\end{exercise}
43034303

@@ -5069,7 +5069,7 @@ \section{Exercises}
50695069
x e^{-x} + \sqrt{1 - e^{-x}}
50705070
\end{eqnarray*}
50715071
%
5072-
{\em Hint:} The method for raising $e$ to a power is \java{Math.exp}.
5072+
{\it Hint:} The method for raising $e$ to a power is \java{Math.exp}.
50735073

50745074
\end{enumerate}
50755075

@@ -5160,7 +5160,7 @@ \section{Exercises}
51605160
\item Explain in a few words what \java{prod} does (without getting into the details of how it works).
51615161

51625162
\item Rewrite \java{prod} without the temporary variables \java{recurse} and \java{result}.
5163-
{\em Hint:} You only need one line for the \java{else} branch.
5163+
{\it Hint:} You only need one line for the \java{else} branch.
51645164

51655165
\end{enumerate}
51665166

@@ -5200,7 +5200,7 @@ \section{Exercises}
52005200

52015201
Write a recursive method called \java{power} that takes a double \java{x} and an integer \java{n} and returns $x^n$.
52025202

5203-
{\em Hint:} A recursive definition of this operation is $x^n = x \cdot x^{n-1}$.
5203+
{\it Hint:} A recursive definition of this operation is $x^n = x \cdot x^{n-1}$.
52045204
Also, remember that anything raised to the zeroth power is 1.
52055205

52065206
Optional challenge: you can make this method more efficient, when \java{n} is even, using $x^n = \left( x^{n/2} \right)^2$.
@@ -6757,12 +6757,12 @@ \section{Exercises}
67576757

67586758
\begin{exercise}
67596759
Write a method named \java{areFactors} that takes an integer \java{n} and an array of integers, and that returns \java{true} if the numbers in the array are all factors of \java{n} (which is to say that \java{n} is divisible by all of them).
6760-
%{\em Hint:} See Exercise~\ref{ex.isdiv}.
6760+
%{\it Hint:} See Exercise~\ref{ex.isdiv}.
67616761
\end{exercise}
67626762

67636763

67646764
\begin{exercise}
6765-
Write a method named \java{arePrimeFactors} that takes an integer \java{n} and an array of integers, and that returns \java{true} if the numbers in the array are all prime {\em and} their product is \java{n}.
6765+
Write a method named \java{arePrimeFactors} that takes an integer \java{n} and an array of integers, and that returns \java{true} if the numbers in the array are all prime {\it and} their product is \java{n}.
67666766
\end{exercise}
67676767

67686768

@@ -6803,7 +6803,7 @@ \section{Exercises}
68036803
%You can read about it at \url{https://en.wikipedia.org/wiki/Binary_search_algorithm}.
68046804
%
68056805
%Write a method called \java{binarySearch} that implements this algorithm.
6806-
%{\em Hint:} You might find it easier to write this method recursively.
6806+
%{\it Hint:} You might find it easier to write this method recursively.
68076807
%
68086808
%\end{exercise}
68096809

@@ -9083,7 +9083,7 @@ \section{Exercises}
90839083

90849084
The implementation of \java{increment} in this chapter is not very efficient.
90859085
Can you rewrite it so it doesn't use any loops?
9086-
{\em Hint:} Remember the modulus operator.
9086+
{\it Hint:} Remember the modulus operator.
90879087

90889088
\end{exercise}
90899089

@@ -9169,7 +9169,7 @@ \section{Exercises}
91699169
\item Write an instance method named \java{reduce} that reduces a rational number to its lowest terms by finding the greatest common divisor (GCD) of the numerator and denominator and dividing through.
91709170
This method should be a pure method; it should not modify the instance variables of the object on which it is invoked.
91719171

9172-
{\em Hint:} Finding the GCD only takes a few lines of code.
9172+
{\it Hint:} Finding the GCD only takes a few lines of code.
91739173
Search the web for ``Euclidean algorithm''.
91749174

91759175
\item Write an instance method called \java{add} that takes a \java{Rational} number as an argument, adds it to \java{this}, and returns a new \java{Rational} object.
@@ -10424,7 +10424,7 @@ \section{Exercises}
1042410424
\index{StringBuilder}
1042510425
\index{efficiency}
1042610426

10427-
{\em Hint:} You can use the \java{+} operator to concatenate strings, but it is not very efficient.
10427+
{\it Hint:} You can use the \java{+} operator to concatenate strings, but it is not very efficient.
1042810428
Consider using \java{java.lang.StringBuilder}; you can find the documentation by doing a web search for ``Java StringBuilder''.
1042910429
\end{exercise}
1043010430

@@ -11234,7 +11234,7 @@ \section{Exercises}
1123411234
Write a loop that plays the game 100 times and keeps track of how many times each player wins.
1123511235
If you implemented multiple strategies in the previous exercise, you can play them against each other to evaluate which one works best.
1123611236

11237-
{\em Hint:} Design a \java{Genius} class that extends \java{Player} and overrides the \java{play} method, and then replace one of the players with a \java{Genius} object.
11237+
{\it Hint:} Design a \java{Genius} class that extends \java{Player} and overrides the \java{play} method, and then replace one of the players with a \java{Genius} object.
1123811238
\end{exercise}
1123911239

1124011240

@@ -11922,7 +11922,7 @@ \section{Exercises}
1192211922
Modify {\tt Mickey.java} to draw ears on the ears, and ears on those ears, and more ears all the way down until the smallest ears are only 3 pixels wide.
1192311923

1192411924
The result should look like ``Mickey Moose'', shown in Figure~\ref{fig.moose}.
11925-
{\em Hint:} You should only have to add or modify a few lines of code.
11925+
{\it Hint:} You should only have to add or modify a few lines of code.
1192611926

1192711927
\begin{figure}[!ht]
1192811928
\begin{center}

0 commit comments

Comments
 (0)