How to i read in a BigInteger from the console prgram??

The exercise was to rewrite a rational number class using BigIntegers ( the original code which uses ints was provided in my study text and is posted here: http://www.java-forums.org/new-java/...tml#post111732

after consulting javadoc and other stuff on google I think i have achieved the goal (at least eclipse shows no compile errors) however i am having a mental block or something, because i cant work out how to test my code because i cannot read in a biginteger.

i have tried various things using scrapbook and a console program . I am assuming that I have to read in a string and convert it to a biginteger.

I arrived at this notion because of entry number 5 in the constructor summary information at javadoc states:

BigInteger(String val)

Translates the decimal String representation of a BigInteger into a BigInteger.

and i am assuming this is the way I must do it,,

it has occured to me however that perhaps my code (despite having no compile errors) is a pile of junk! so ive posted it below.

also there is something about throwing exceptions which i may not have done in the conventional way, i am not concerned with this too much at the moment, but any suggestions on throwing exceptions will be gratefully accepted.

BigRational code:

Code:`import java.math.BigInteger;`

import acm.util.ErrorException;

public class BigRational {

private BigInteger numerator;

private BigInteger denominator;

public BigRational(){

this(BigInteger.ZERO);

}

public BigRational(BigInteger numerator){

this(numerator,BigInteger.ONE);

}

public BigRational(BigInteger numerator, BigInteger denominator) {

if (BigInteger.ZERO == denominator)

throw new ErrorException("Cannot divide by zero.");

BigInteger gcd = numerator.abs().gcd(denominator.abs());

this.numerator = numerator.divide(gcd);

this.denominator = denominator.divide(gcd);

}

public BigRational add(BigRational r) {

return new BigRational

(this.numerator.multiply(r.denominator)

.add(r.numerator.multiply(this.denominator)),

this.denominator.multiply(r.denominator));

}

public BigRational subtract(BigRational r) {

return new BigRational(this.numerator.multiply(r.denominator)

.subtract(r.numerator).multiply(this.denominator),

this.denominator.multiply(r.denominator));

}

public BigRational multiply(BigRational r) {

return new BigRational(this.numerator.multiply(r.numerator),

this.denominator.multiply(r.denominator));

}

public BigRational divide(BigRational r) {

return new BigRational(this.numerator.multiply(r.denominator),

this.denominator.multiply(r.numerator));

}

public String toString() {

if (denominator == BigInteger.ONE) {

return "" + numerator;

} else {

return numerator + "/" + denominator;

}

}

}