Lab 2110 - Hailstone


In a strong thunderstorm, raindrops are often hurled high in the storm by winds rushing aloft, where the raindrops freeze. Falling again, they reach lower altitudes where winds may again carry them higher in the storm. Each time, a new layer of ice forms, making a hailstone that increases in size as it continues its rising-falling path. Eventually it falls from the storm.

It is the path of the hailstone that gives rise to the name of this project. Here we simulate a hailstone using a sequence of numbers derived from a simple formula.


Write a program to calculate the path of a hailstone starting at a given altitude. This project used the Model-View-Controller design pattern. Your teacher will provide code for the View and the Controller components. You must write the missing parts of the model class.

The file is provided to you looking like this:

public class HailstoneModel
    private int[] mySteps;
    private HailstoneView myView;

    // constructor is given a reference to the view component it should use
    public HailstoneModel(HailstoneView view)
        mySteps = new int[Hailstone.MAXSTEPS];
        myView = view;
    public void solve(int n)
        ... student code here ...
        // display results

You will be provided with the controller:, and the view component: These files, along with EasyReader, can be used without modification to complete this project.

Copyright © 2010 by Asylum Computer Services LLC Return to CS Labs