User Tools

Site Tools


cs175:methods_lab_-_tryrandom3_using_randbetween_method

TryRandom3, using the randbetween method


TryRandom2.java introduced the Math.random() method to generate random integers.

We want to write a more convenient way to generate random integers within a certain range.

The method we want to write and use is called randbetween. It begins like this:

        /**
         *  randbetween method
         *  input parameters: low number, high number, int
         *  output (return):  random int value between low and high
         */ 
        public static int randbetween( int low, int high )

In the TryRandom3.java program, define and use the randbetween method.

Link to TryRandom3.java source


cs175/methods_lab_-_tryrandom3_using_randbetween_method.txt · Last modified: 2014/11/04 21:18 by jchung

Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki