title: Decimal multiplication without * operator using java
body: <p>The below code works accurate on int </p>
  
  <pre><code>public class Example {
      public static void main(String[] args) {
  
          int a = 3, b = 3, mul = 0;
  
          // mul = a * b //this should not be used
  
          for (int i = 1; i &lt;= a; i++)
              mul = mul + b;
  
          System.out.println(a + "*" + b + "--&gt;" + mul);
      }
  }
  </code></pre>
  
  <p>output :
  3*3-->9
  Now this is perfect </p>
  
  <p>But when i used double :</p>
  
  <pre><code>public class Example {
      public static void main(String[] args) {
  
          double a = 3.5, b = 3.5, mul = 0;
  
          // mul = a * b //this should not be used
  
          for (int i = 1; i &lt;= a; i++)
              mul = mul + b;
  
          System.out.println(a + "*" + b + "--&gt;" + mul);
      }
  }
  </code></pre>
  
  <p>output:</p>
  
  <p>3.5*3.5-->10.5 
  Now this is wrong since the correct answer of </p>
  
  <p>3.5*3.5-->12.25</p>
  
  <p>The problem is i need to multiply decimal values where as for loop wont support iteration over double value.</p>