sum of two random integers between 1 and 6
<pre><code>public class SumOfTwoDice { 
    public static void main(String[] args) {
        int SIDES = 6;
        int a = 1 + (int) (Math.random() * SIDES);
        int b = 1 + (int) (Math.random() * SIDES);
        int sum = a + b;
        System.out.println(sum);
    }
}
</code></pre>

<p>Here is the above code to find out the sum of two random integers between 1 and 6 or any given number. </p>

<p>The below is my own written code, Is this fine. The way i am achieving the Sum of Two random integers. <strong>Is this Correct</strong> ???</p>

<pre><code>public class TestSample {
    public static void main(String[] args) { 

        int a = Integer.parseInt(args[0]); // 1
        int b = Integer.parseInt(args[1]); // 6
        double ran = Math.random();
        System.out.println("Random Number" + ran);
        double random;

        if(a &lt; b)
            random = (b-a)*ran + a;
        else
            random = (a-b)*ran + b;

        double sum = random + random;
        System.out.println("Random Number" +(int)sum);
    }
}
</code></pre>
