Java #38: Using the Math.random Function to Create two Random Doubles

————Full Source Code———-
//Programmer: Akinwale Owi
//Company: Dagba Computers
//Program Purpose:Use the math.random function to create some random values for variables

package dagbacomputers;

/**
*
* @author Akin
*/

//imports
import java.lang.*;

public class DagbaComputers {

/**
* @param args the command line arguments
*/
public static void main(String[] args)
{
//Variable that I will use the math.random function with plainly
double normal = Math.random();

//Printing out normal Variable
System.out.println(“Plain math.random gave me the value: ” + normal);

//Creating Variable that will be between 1 and 1000
double thousand = Math.random() * 1001;

//printing out the thousand variable
System.out.println(“One to a thousand: ” + thousand);

//Creating Variable that will be between 1 and 100
double hundred = Math.random() *101;

//printing ou the hundred variable
System.out.println(“Between one and a hundred: ” + hundred);

}//end of main
}//End of DagbaComputers Class

————-End of Program————–
—————Output————-

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Blog at WordPress.com.

Up ↑

%d bloggers like this: