
-----------------------------------
Flashkicks
Thu Feb 10, 2005 1:35 pm

Generating Multiple Random Numbers
-----------------------------------
This is an assignment I have, and the following is the coding.  I can not get the "generate 5 random numbers between 1-10" part. // The "PowerExample" class.
public class PowerExample
{
    public static void main (String [] args)
    {
        // declare variables
        int valueOne, valueTwo;
        double answer, randomValue1, randomValue2, randomValue3, randomValue4, randomValue5;

        //initialize
        valueOne = 4;
        valueTwo = 12;

        //use Math class to find 4^12
        answer = Math.pow (4, 7);
        System.out.println (answer);

        System.out.println (Math.sqrt (12)); // square root of 12

        System.out.println (Math.abs (4 - 12)); // absolute of 4-12

        /* Math.random () */

//  this whole secion here..  This is Ugly!
        randomValue1 = ((Math.random () * 10) + 1); // displays 5 random nums
        randomValue2 = ((Math.random () * 10) + 1); // displays 5 random nums
        randomValue3 = ((Math.random () * 10) + 1); // displays 5 random nums
        randomValue4 = ((Math.random () * 10) + 1); // displays 5 random nums
        randomValue5 = ((Math.random () * 10) + 1); // displays 5 random nums
        System.out.println (randomValue1 + "  " + randomValue2 + "  " + randomValue3);
        System.out.println (randomValue4 + "  " + randomValue5);
    } // main method
} // PowerExample class

//experiment with the various methods in the Math class.

//1.  Find the square root of 12
//2.  Find the absolute value of 4 - 12
//3.  Declare a real (double) variable randomValue.  Your program should display five random values between 0 and 10.
//4.  Find 5 random values between 11 and 95
//5.  Make up two questions and display the answer.


~Flashkicks

-----------------------------------
Tony
Thu Feb 10, 2005 1:40 pm


-----------------------------------

for(int i=0;i