/* 
 *  This is professor Adam's long winded way to get to
 *  code to generate a random number in range 1 to 25
 *  using Math.random()  
 *
 *  line 65 condenses all the steps into 1 & is embedded
 *  in a for loop to show 100 values.
 *
 *  @author Elizabeth Adams
 *  @version 1.2
*/ 
public class LongWindedPlayWithRandomFromMath
{
   public static void main (String args [])
	{
	    double valueReturned;
		 int    valueDesired;
		 double modifiedValue;
		 		
				
		 // the purpose of this for loop is to look at
		 // a number of returned values not just 1 of them		 
       for (int i = 0; i < 10; i++)
       {	 	 
		    valueReturned = Math.random();
	   	 System.out.println 
	      (" value returned by Math.random() is " + valueReturned);
		 
		 // I want value returned to be in range 1 to 25 
		 // and it's between 0.0 and 1.0 so what should I do?
       // multiply by 100 so value will be between 0.0 and 100.0
		    modifiedValue = 100 * valueReturned;
    		 System.out.println 
		      ( " modified value is " + modifiedValue);

       // now the integer portion is okay how do I get
		 // rid of the fraction?  
		 //  and convert to an integer which truncates 
  		    valueDesired = (int) modifiedValue;
       	 System.out.println
		     ( " value desired is " + valueDesired);

		 // is that the correct answer? no! 
		 // values are not in range 1 to 25
		 // use the mod function to get a numbers in range 0 to 24
  		    valueDesired = valueDesired%25;
  		    System.out.println
  		       ( " now value desired is " + valueDesired);
 	  
		 // is that the correct answer? no! want 1 to 25
		 // what should I do?
		 // add 1 to answer
 		   valueDesired = valueDesired + 1;
		   System.out.println
		    (  " final answers of value desired is "
			    + valueDesired);
     }// end for


      // this final for loop just combines all the steps
		// using parentheses for control the order of operations
		// where necessary 
		for (int i = 0; i < 100; i++)
	   {
		   valueDesired = (int)(Math.random()*100)%25 +1;
			System.out.print (valueDesired + " ");
		 } // end for 
  	}// end main
}// end class
		 
		 