title: Rational Numbers in Java
body: <p>I'm doing the following for a lab, and am getting everything to compile with the file they gave us apart from the last method named "divide". The point of it is to do different operations using Rational numbers. My This is my code for the divide method. I also included the name of the class:</p>
  
  <pre><code>public class Rational{
  
    public Rational divide (Rational newRational){
      int numer = (numerator / newRational.getNum());
      int denom = ( denominator / newRational.getDenom());
      return new Rational (numer, denom);
    }
  }
  </code></pre>
  
  <p>The code we were given to have it compile with is the following. The rest of my code (not included here) compiles perfectly with this when I comment out the last two lines that have to deal with the divide method above. </p>
  
  <pre><code>public class RationalDemo{
      public static void main(String args[])
      {
          Rational r1= new Rational (3,4);
  
          Rational r2= new Rational (1,4);
  
          Rational addResult = r1.add(r2);
          System.out.println(addResult.toString()); //1
  
          Rational subtractResult = r1.subtract(r2);
          System.out.println (subtractResult.toString()); //1/2
  
          Rational multiplyResult = r1.multiply(r2);
          System.out.println(multiplyResult.toString());//3/16
  
          Rational.divideResult= r1.divide(r2);
          System.out.println(divideResult.toString());//3
       }
  }
  </code></pre>
  
  <p>The error I get when trying to compile is:</p>
  
  <blockquote>
    <p>2 errors found:
    [line: 17]
    Error: cannot find symbol
      symbol:   variable divideResult
      location: class Rational
     [line: 18]
    Error: cannot find symbol
      symbol:   variable divideResult
      location: class RationalDemo</p>
  </blockquote>
  
  <p>I'm not sure what I am doing wrong here or why this error message is popping up. </p>