RunCollatz - public int nextInt return_s.nextInt...

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
// -------------------------------- // projects/collatz/RunCollatz.java // Copyright (C) 2010 // Glenn P. Downing // -------------------------------- /* To run the program: % javac -Xlint RunCollatz.java % java -ea RunCollatz < RunCollatz.in > RunCollatz.out To document the program: % javadoc -d html -private *.java */ import java.io.PrintStream; import java.util.Scanner; // ------ // Reader // ------ final class Reader { private Scanner _s; public Reader () { _s = new Scanner(System.in);} public boolean hasNextInt () { return _s.hasNextInt();}
Background image of page 1
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: public int nextInt () { return _s.nextInt();}} // ------// Writer // ------final class Writer { private PrintStream _ps; public Writer () { _ps = System.out;} public void write(String s) { _ps.println(s);}} // ----------// RunCollatz // ----------final class RunCollatz { public static void main (String args) { final Reader r = new Reader(); final Writer w = new Writer(); final int a = new int[2]; while (Collatz.read(r, a)) { final int v = Collatz.eval(a); Collatz.print(w, a, v);}}}...
View Full Document

{[ snackBarMessage ]}

Ask a homework question - tutors are online