This is my latest java project in my 2nd level java course. This code functions properly and works well with my driver class(not uploaded). I am wondering if there are any improvements i could make to the code as well as wondering about my tabbing and commenting. My instructor has not really explained to us what we should comment and what we shouldn't comment.

/* Fraction methods for adding, subtracting, multiplying, and dividing rational number * also will have to compute greatest common denominator for use with the add/subtract * feature and can reduce the numbers after the appropriate operations have been completed. * version 1.3 */ public class Fraction { private int num; //numerator private int den; //denominator public Fraction(int n, int d) // constructor that requires 2 digits of input { // assign num = n & den = d as long as d!= 0 if(d != 0) { num = n; den = d; } else System.exit(0); } private static int gcd(int x, int y) { /* gcd() method finds the greatest common divisor of * the 2 int variables passed and returns that value * */ int mod; // hold a value temporarily to allow switch if(x < y) // always use the larger value as the divisor { mod = x; x = y; y = mod; } int r = x % y; // r holds the remainder of modulus division while (r != 0) // while modulus division does not result in zero { x = y; y = r; r = x % y; } return y; } private Fraction reduce(int n, int d) { int gcdNum = gcd(n,d); d = d / gcdNum; // reduce the denominator using the gcd foun in gcd method n = n / gcdNum; // reduce the numerator using the gcd foun in gcd method return new Fraction(n,d); // return the new fraction object in lowest form } public Fraction add(Fraction b) { int num1 = (this.num * b.den) + (b.num * this.den); // cross multily and add int num2 = this.den * b.den; // multiply the denominators to make them equivlent return reduce(num1,num2);// calls reduce() method and returns a new Fraction object } public Fraction subtract(Fraction b) { int num1 = (this.num * b.den) - (b.num * this.den);// cross multiply and subtact int num2 = this.den * b.den; return reduce(num1,num2);// sends to reduce method } public Fraction multiply(Fraction b) { int num1 = this.num * b.num; // multiplys straight accross int num2 = this.den * b.den; return reduce(num1,num2);// sends to reduce method and returns the reduced fraction to the toString() method } public Fraction divide(Fraction b) { int num1 = this.num * b.den; //multiplys the inverse of 2nd fraction object to divide int num2 = this.den * b.num; return reduce(num1, num2);// sends to reduce method } public String toString() // *** convert to a mixed fraction for output only { if(num > den && den > 1) //if true will show fraction object and mixed number return (num + "/" + den + " or " + (num/den) + " " + (num % den) + "/" + den); else return(num + "/" + den); //will not try to convert fraction object to mixed number } }

Thank you very much for any and all input

~Luc