Advertisement
Guest User

Proj09

a guest
Nov 18th, 2019
115
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.19 KB | None | 0 0
  1. import java.util.*;
  2. import java.lang.Object;
  3. import java.util.Arrays;
  4.  
  5. class Proj09{
  6. static String[] names =
  7. {"Don","don","Bill","bill","Ann","ann","Chris","chris"};
  8.  
  9. static String[] myArray = new String[8];
  10.  
  11. public static void main(String args[]){
  12.  
  13. Proj09Runner runner = new Proj09Runner();
  14.  
  15. int seed = Integer.parseInt(args[0]);
  16. Random generator = new Random(seed);
  17.  
  18. //Create and display the data for input to the class
  19. // named Proj09Runner.
  20. System.out.print("Input: ");
  21. for(int cnt = 0;cnt < 8;cnt++){
  22. int index = ((byte)generator.nextInt())/16;
  23. if(index < 0){
  24. index = -index;
  25. }//end if
  26. myArray[cnt] = names[index];
  27. System.out.print(myArray[cnt] + " ");
  28. }//end for loop
  29. System.out.println();//new line
  30.  
  31. //Process the data and display the results.
  32. Collection collection = runner.getCollection(myArray);
  33.  
  34. System.out.print("Output: ");
  35. Iterator iter = collection.iterator();
  36. while(iter.hasNext()){
  37. System.out.print(iter.next() + " ");
  38. }//end while loop
  39. System.out.println();
  40.  
  41. }//end main()
  42. //----------------------------------------------------//
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement