title: Java error: The method add(String) is undefined for the type String
body: <p>Whenever I try to run my code, I get the error "The method add(String) is undefined for the type String," "The method subtract(String) is undefined for the type String," and so on for the multiply and divide methods. I don't know if the rest of my code runs correctly because I haven't been able to run the actual program. Why am I getting this error?</p>
  
  <p><strong>Main:</strong></p>
  
  <pre><code>import java.util.*;
  
  public class RationalNumberMain 
  {
  
        public static void main(String[] args) 
        {
  
            Scanner s = new Scanner(System.in);
  
            System.out.print("Enter first fraction here: ");
            String r1 = s.nextLine();
  
            System.out.print("Enter second fraction here: ");
            String r2 = s.nextLine();
  
            RationalNumber x = new RationalNumber(r1);
            RationalNumber y = new RationalNumber(r2);
  
              System.out.println("Rational Number 1 is " + r1);
              System.out.println("Rational number 2 is " + r2);
              System.out.println(r1 + " + " + r2 + " = " + r1.add(r2));
              System.out.println(r1 + " - " + r2 + " = " + r1.subtract(r2));
              System.out.println(r1 + " * " + r2 + " = " + r1.multiply(r2));
              System.out.println(r1 + " / " + r2 + " = " + r1.divide(r2));
        }
  }
  </code></pre>
  
  <p><strong>Class:</strong></p>
  
  <pre><code>public class RationalNumber 
  {
  
      private String fraction;
      private String s1;
      private String s2;
      private int num;
      private int den;
      private int combineNum;
      private int combineDen;
      private String finalFraction;
      private int divideNum;
      private int divideDen;
  
  
      public RationalNumber(String userFraction) 
      {
          fraction = userFraction;
          s1 = "";
          s1 = "";
          num = 0;
          den = 0;
          combineNum = 0;
          combineDen = 0;
          finalFraction = "";
          divideNum = 0;
          divideDen = 0;
      }
  
      public String toString() 
      {
          return fraction;
      }
  
      public void seperate()
      {
          s1 = fraction.substring(0,1);
          s2 = fraction.substring(2);
          num = Integer.parseInt(s1);
          den = Integer.parseInt(s2);
  
      }
  
      public int getNum() 
      {
          return num;
      }
  
      public int getDen() 
      {
          return den;
      }
  
      public String add(RationalNumber x) 
      {
          combineDen = den * x.getDen();
          combineNum = (num * x.getDen()) + (x.getNum() * den);
          finalFraction = String.valueOf(combineDen) + "/" + String.valueOf(combineNum);
          return finalFraction;
      }
  
      public String subtract(RationalNumber x) 
      {
          combineDen = den * x.getDen();
          combineNum = (num * x.getDen()) - (x.getNum() * den);
          finalFraction = String.valueOf(combineDen) + "/" + String.valueOf(combineNum);
          return finalFraction;
      }
  
      public String multiply(RationalNumber x) 
      {
          combineDen = den * x.getDen();
          combineNum = num * x.getNum();
          finalFraction = String.valueOf(combineDen) + "/" + String.valueOf(combineNum);
          return finalFraction;
      }
  
      public String divide(RationalNumber x) 
      {
          divideNum = x.getDen();
          divideDen = x.getNum();
          combineDen = den * divideDen;
          combineNum = num * divideNum;
          finalFraction = String.valueOf(combineDen) + "/" + String.valueOf(combineNum);
          return finalFraction;
      }
  
  }
  </code></pre>