H contains a number of functions (sometimes called methods) that simplify input, output, and graphics. Here is a summary of the methods available:
You can find the source code in the downloaded files for CS 5 in the H.java and G.java files inside the source_code folder of each problem. However, unless you're trying to extend the available capabilities, it's probably easier to use these reference pages. And if anything isn't working for you, please let us know at dodds@cs.hmc.edu or bthom@cs.hmc.edu
Here is a summary of what is available.
In these examples, x can be a variable of almost
any type. N is an integer. d is a
double-precision value.
H.pl(x)
prints x followed by a newline. That is, subsequent
printing will start on the next line.
H.pl()
prints only a newline.
H.p(x)
prints whatever x is. No newline is appended.
H.cls()
"clears" the screen by printing 50 newlines.
H.nl()  
returns the next line of text the user types (up to a newline '\n')
H.nw()  
returns the next word the user types (up to whitespace)
H.nc()  
returns the next non-whitespace char the user types or has typed.
H.nanyc()  
returns the next char the user types or has typed.
H.ni()  
returns the next integer the user types or has typed.
H.nd()  
returns the next double the user types or has typed.
H.nlong()  
returns the next long the user types or has typed.
H.randInt(low,high) returns a random integer between low
and high inclusive.
H.randDouble(low,high) returns a random double-precision value between low
and high exclusive of high.
H.fmt(d) does not, in fact, print anything on the
screen -- at least not by iteself. Instead, it returns a String that can be printed by
one of the above printing commands. It's probably best explained through
these four lines of code and what they print:
H.pl("pi is " + H.fmt(d) + " or so"); prints pi is 3.142 or so
H.pl("pi is " + H.fmt(d,5) + " or so"); prints pi is 3.14159 or so
H.pl("pi is " + H.fmt(d,5,15) + " or so"); prints pi is 3.14159 or so
H.pl("pi is " + H.fmt(d,5,15,HMCOutput.RIGHT) + " or so"); prints pi is 3.14159 or so
H.fmt(d) uses 3 places of precision after the decimal point, rounding as appropriate.
H.fmt(d,N) uses N places of precision.
H.fmt(d,N,W) uses at least W spaces to do the formatting.
H.fmt(d,N,W,side) places the number d to the left, right, or center, depending
on whether side is HMCOutput.LEFT or HMCOutput.RIGHT or
HMCOutput.CENTER.
H.out.setWidth(N)  
makes future printing commands use at least N spaces each.
H.out.setPadChar(C)  
replaces unused space in those N spaces with the character
C in future printing.
H.out.setRightJustify()  
makes future printing align to the right.
H.out.setCenterJustify()  
makes future printing align to the center.
H.out.setLeftJustify()  
makes future printing align to the left.
H.out.setPrecision(N)  
sets N places of precision to the right of
the decimal point for doubles.
H.out.setFixed(true)  
adds trailing zeros when printing doubles so
that all of the places of precision are used.
You can also use false in place of true
to turn this off.
H.inputFromConsole()  
sets future user input to come from the console (the default).
H.inputFromFile(String filename)  
will set future input to come from the file filename. That file
should be in the same directory as the CS5App.java file.
H.inputToFile(String filename)  
will send future input to the file filename. If filename
already exists, it gets overwritten. This is useful for storing your input to
complicated programs and replaying it without retyping it all... .
H.outputToConsole()  
sets future output to go to the console (the default).
H.outputToFile(String filename)  
will send future output to the file filename. If filename
already exists, it gets overwritten.