CS 305J Coding Samples
Java programs to illustrate various concepts
- Program with syntax
errors. A program with multiple syntax errors to find and fix.
- Scratch.java. Various simple examples
of the behavior of variables and the results of expressions.
An unstructured program that prints out a diamond, an X, and a rocket.
A structured program that prints out a diamond, an X, and a rocket.
The code from class used to draw different sized Xs and Vs.
HourGlass Our program
for drawing an hour glass.
Small program with some simple methods that use parameters.
- FToCConverter.java A very
simple class that converts a given temperature in degrees Fahrenheit to its
equivalent temperature on the Celsius scale.
- BaseballStats. A
simple program that calculates various baseball batting statistics.
- Coin Flipping. A
program that asks the user how many times to simulate flipping a coin. It then
reports how many heads, how many tails, and what the longest streak of flips
- Target. A
program that simulates shooting at a target.
- FileOps. A program with
some examples of working with files.
- Histogram. A program
that produces a histogram based on exam scores.
Here is a sample data file.
- Anagrams. A program with
a method that tests if two strings are anagrams of each other.
- Conway' Game of Life. A
simple version of Conway's Game of Life. Lots of examples of working with a 2D
- Card. A class to model
standard playing cards.
- Deck. A class to model a deck
of standard playing cards.
- The classes we did in class to show how inheritance and interfaces work.
Circle, and a
A program that shows various manipulations of Rectangle objects.
- Point.java A class that models a Cartesian
- Circle.java A class that model a
- Loops2 Contains a method that
approximates square roots using Newton's method and a method that determines
if a given int is prime or not.
- Loops3 Contains methods for the
- a method that determines if a String is a valid representation of a
strand of DNA in that it only contains the characters A, C, G, and T
- a method that determines if two Strings are complimentary strands of DNA
- a method that computes N! using ints
- ArrayEx Various
algorithms and methods that work on and with arrays.
- ArrayListExamples Simple
examples of manipulations of ArrayList objects