List of Sample Programs
Example 1.1
Computes the surface area of a sphere.
Java concepts: The type double,
input, formatted output, assignment.
Example 1.2
Computes the surface area increase.
Java Concepts: Inputting more than one numerical value.
Example 1.3
Illustrates the double angle formulae for sine and cosine.
Java Concepts: Math.cos, Math.sin, Math.abs, using a temporary
variable.
Example 1.4
Minimum of x^2 + bx + c on [L,R].
Java Concepts: nest if-else.
Example 1.5
Leap year identification.
If a year is divisible by 4,then it is a leap year with the exception
of century years that are not divisible by 400.
Java Concepts: The int type, integer arithmetic, the && operation,
nested if-else.
Example 1.6
Computes the number of leap year days in between January 1, 1900
and December 31 of any year from 1900 to 2099.
Java Concepts: Integer i/o, integer arithmetic.
Example 2.1
Areas of regular polygons that are inscribed and circumscribed
in the unit circle.
Java concepts: For-loop, loop bounds, multiple data on a single output line.
Example 2.2
Table of Areas for regular polygons inscribed and circumscribed in the unit circle.
Java concepts: For loop with nonunit step.
Example 2.3
Explores convergence of polygon area approximation to pi.
Java concepts: Constants, While-loops
Example 2.4
Explores convergence of polygon area approximation to pi.
Java concepts: Constants, While-loops, updating variables
Example 2.5
Confirms that 3^(2n+1) + 2^(n+2) is divisible by 7 for n=0,...,9.
Java concepts: The long type, the for-loop, integer arithmetic.
Example 2.6
Explores floating point precision.
Java concepts: Exponentiation, while-loops.
"Classes and Objects: The Quadratic Example".
Illustrates various computations that involve quadratic polynomials.
Java concepts: Classes, Objects.
"Classes and Objects: The Sine/Cosine Example".
Examines the accuracy of a cosine approximation.
Java concepts: Classes, Objects.
"Classes and Objects: The Point/Line Example".
Illustrates various geometric computations that involve points and lines.
Return to CS100B Homepage
If you have any questions or comments about this page, please contact me:
kyparlis@cs.cornell.edu
Latest update: 09/03/1997