Assignemnt #53 and Randomness.java

Code

    /// Name: Boris Kazantsev
    /// Period: 6
    /// Program Name: Randomness
    /// File Name: Randomness.java
    /// Date Finished: 1/6/2016
    
    
    import java.util.Random;
    
    public class Randomness
    {
    	public static void main ( String[] args )
    	{
    		Random r = new Random(); // if you put a value to the seed, the results of random numbers are consistent
    
    		int x = 1 + r.nextInt(10);
    
    		System.out.println( "My random number is " + x );
    
    		System.out.println( "Here are some numbers from 1 to 5!" );
    		System.out.print( 3 + r.nextInt(5) + " " ); // 1 + prevents getting a number 0.
    		System.out.print( 3 + r.nextInt(5) + " " ); // "3 +" sets starting number 3 so you will get 3 - 5 range of #s.
    		System.out.print( 3 + r.nextInt(5) + " " );
    		System.out.print( 3 + r.nextInt(5) + " " );
    		System.out.print( 3 + r.nextInt(5) + " " );
    		System.out.print( 3 + r.nextInt(5) + " " );
    		System.out.println();
    
    		System.out.println( "Here are some numbers from 1 to 100!" );
    		System.out.print( 1 + r.nextInt(100) + "\t" );
    		System.out.print( 1 + r.nextInt(100) + "\t" );
    		System.out.print( 1 + r.nextInt(100) + "\t" );
    		System.out.print( 1 + r.nextInt(100) + "\t" );
    		System.out.print( 1 + r.nextInt(100) + "\t" );
    		System.out.print( 1 + r.nextInt(100) + "\t" );
    		System.out.println();
    
    		int num1 = 1 + r.nextInt(10);
    		int num2 = 1 + r.nextInt(10);
    
    		if ( num1 == num2 )
    		{
    			System.out.println( "The random numbers were the same! Weird." );
    		}
    		if ( num1 != num2 )
    		{
    			System.out.println( "The random numbers were different! Not too surprising, actually." );
    		}
    	}
    }

        
        
                   
    

Picture of the output

Assignment 53