StefanTobler

Lesson 33 Activity 2

Dec 3rd, 2016
162
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | None | 0 0
  1. /*
  2.  * Lesson 33 Coding Activity 2
  3.  *
  4.  * For the Lesson 33 activities, you will be asked to write one or more methods.
  5.  * Use the template to write a main method that tests each of your methods,
  6.  * then paste everything into the code runner box. Your submission should
  7.  * begin with the first import statement and end with the final }.
  8.  *  
  9.  * For questions 2-5, you may want to start with the printIt method
  10.  * and use it to test the other three.
  11.  *  
  12.  * Write a method that takes an array of ints and stores random numbers
  13.  * between 10 and 99 in the array. Use Math.random() to generate
  14.  * random numbers and convert them to integers between 10 and 99 inclusive.
  15.  *
  16.  * This method must be called randomize() and it must take an int[] parameter.
  17.  *
  18.  */
  19.  
  20.  
  21. import java.util.Scanner;
  22.  
  23. class Lesson_33_Activity_Two {
  24.  
  25.     public static void randomize(int x[])
  26.     {
  27.       for (int i = 0; i < x.length; i++)
  28.       {
  29.         x[i] = (int)(Math.random()*90)+10;
  30.       }
  31.     }
  32.  
  33.     public static void main(String[] args)
  34.      {
  35.       int x[] = new int[3];
  36.      randomize(x);
  37.      for (int i = 0; i < x.length; i++)
  38.        System.out.print(x[i] + " ");
  39.     }
  40. }
Add Comment
Please, Sign In to add comment