Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package fractions;
- public class Fraction {
- private int numerator;
- private int denominator;
- public Fraction(int n, int d) throws ArithmeticException {
- if (d == 0) {
- throw new ArithmeticException("denominator is zero");
- }
- else if (n==0) {
- d = 1;
- n = 0;
- }
- else if (d<0 ) {
- n = -n;
- d = -d;
- }
- else{
- gcd(n, d);
- }
- }
Add Comment
Please, Sign In to add comment