title: How to add fractions in Java
body: <p>I am trying to make a simple program that adds two fractions.</p>
  
  <pre><code>    public static void add(int nom1, int denom1, int nom2, int denom2){
  
      int comd = denom1*denom2; //creates common denominator by multiplying both denominators
  
      int answer = nom1*nom2+nom1*nom2; //attempting to get answer (not working very well)
  
      System.out.println(nom1+"/"+denom1+" + "+nom2+"/"+denom2+" = "+answer+"/"+comd); // outputs   test like 1/2 + 4/8 = 8/8
  
      start(); // restarts the program
  }
  </code></pre>
  
  <p>Unfortunately, my calculation to find the sum doesnt work, and i can not figure out another way of doing this. Thanks in advance for anyone who helps. Sorry if this seems noobish, but I can't find anything online that works that I can understand.</p>