Java Programs in the Textbook
Standard libraries.
Here are the standard input and output libraries that we use throughout the textbook.
Programs in the textbook.
Below is a table of the Java programs in the textbook. Click on the program name to access the Java code; click on the reference number for a brief description; read the textbook for a full discussion. You can download all of the programs as introcs.jar and the data as introcs-data.zip.
Exercise solutions.
Here is a list of solutions to selected coding exercises.
| 1 | ELEMENTS OF PROGRAMMING | |
|---|---|---|
| 1.1.1 | TenHelloWorlds.java | ten Hello, Worlds |
| 1.1.5 | UseThree.java | three command-line arguments |
| 1.2.20 | SumOfTwoDice.java | sum of two dice |
| 1.2.23 | SpringSeason.java | is month and day in Spring? |
| 1.2.25 | WindChill.java | compute wind chill factor |
| 1.2.26 | CartesianToPolar.java | Cartesian to polar coordinates |
| 1.2.29 | DayOfWeek.java | compute day of week from date |
| 1.2.30 | Stats5.java | average, min, max of 5 random numbers |
| 1.2.34 | ThreeSort.java | sort three integers |
| 1.2.35 | Dragon.java | dragon curve of order 5 |
| 1.3.8 | FivePerLine.java | print integers five per line |
| 1.3.11 | FunctionGrowth.java | table of functions |
| 1.3.12 | DigitReverser.java | reverse digits |
| 1.3.13 | Fibonacci.java | Fibonacci numbers |
| 1.3.15 | SeriesSum.java | convergent sum |
| 1.3.20 | BinaryToString.java | binary number to string conversion |
| 1.3.31 | Ramanujan.java | taxicab numbers |
| 1.3.32 | ISBN.java | ISBN checksum |
| 1.3.38 | Sin.java | sine function via Taylor series |
| 1.3.41 | MonteHall.java | Monte Hall problem |
| 1.4.2 | HugeArray.java | creating a huge array |
| 1.4.10 | Deal.java | deal poker hands |
| 1.4.13 | Transpose.java | tranpose a square matrix |
| 1.4.25 | InversePermutation.java | compute inverse permutation |
| 1.4.26 | Hadamard.java | compute Hadamard matrix |
| 1.4.30 | Minesweeper.java | create Minesweeper board |
| 1.4.33 | RandomWalkers.java | N random walkers |
| 1.4.35 | Birthdays.java | birthday problem |
| 1.4.37 | BinomialCoefficients.java | binomial coefficients |
| 1.5.1 | MaxMin.java | max and min from standard input |
| 1.5.3 | Stats.java | mean and stddev from standard input |
| 1.5.5 | LongestRun.java | longest consecutive run from stdin |
| 1.5.11 | WordCount.java | word count from standard input |
| 1.5.15 | Closest.java | closest point |
| 1.5.18 | CheckerBoard.java | draw a checkerboard |
| 1.5.21 | Rose.java | draw a rose |
| 1.5.22 | Banner.java | animate a text banner |
| 1.5.31 | Spirograph.java | draw spirograph |
| 1.5.32 | Clock.java | animate a clock |
| 1.5.33 | Oscilloscope.java | simulate an oscilloscope |
| 2 | FUNCTIONS | |
| 2.1.4 | ArrayEquals.java | are two integer arrays equal? |
| 2.1.30 | BlackScholes.java | Black-Scholes option valuation |
| 2.1.32 | Horner.java | Horner's method to evaluate a polynomial |
| 2.1.33 | Benford.java | Benford's law |
| 2.1.38 | Calendar.java | create a calendar |
| 2.2.1 | Gaussian.java | overloaded gaussian distribution functions |
| 2.2.2 | Hyperbolic.java | hyperbolic trig functions |
| 2.2.4 | StdRandom.java | shuffle an array of doubles |
| 2.2.6 | StdArrayIO.java | array IO methods |
| 2.2.11 | Matrix.java | matrix operations |
| 2.2.12 | MarkovSquaring.java | page rank via matrix squaring |
| 2.2.14 | StdRandom.java | exponential random variable |
| 2.3.14 | AnimatedHtree.java | animated H-tree |
| 2.3.15 | IntegerToBinary.java | integer to binary conversion |
| 2.3.17 | Permutations.java | all permutations |
| 2.3.18 | PermutationsK.java | all permutations of size k |
| 2.3.19 | Combinations.java | all combinations |
| 2.3.20 | CombinationsK.java | all combinations of size k |
| 2.3.22 | RecursiveSquares.java | recursive squares |
| 2.3.24 | GrayCode.java | Gray code |
| 2.3.26 | AnimatedHanoi.java | animated Towers of Hanoi |
| 2.3.29 | Collatz.java | Collatz function |
| 2.3.30 | BrownianIsland.java | Brownian island |
| 2.3.31 | PlasmaCloud.java | plama cloud |
| 2.3.32 | McCarthy.java | McCarthy's 91 function |
| 2.3.33 | Tree.java | fractal tree |
| 2.4.15 | PercolationDirectedNonrecursive.java | directed percolation |
