Advertisement
Blonk

Untitled

Feb 25th, 2020
121
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 2.06 KB | None | 0 0
  1. import java.util.Random;
  2. import java.util.*;
  3. import java.util.concurrent.ThreadLocalRandom;
  4. import java.util.Scanner;
  5.  
  6. public class Main {
  7.  
  8.     public static void main(String[] args) {
  9.  
  10.         Random rand = new Random();
  11.  
  12.         int[] myList;
  13.         myList = new int[10];
  14.         int[] my2List;
  15.         my2List = new int[10];
  16.         int[] my3List;
  17.         my3List = new int[10];
  18.  
  19.         System.out.print("First Array: ");
  20.         for (int i = 0; i < myList.length; i++) {
  21.             myList[i] = 1 + rand.nextInt(50);
  22.             System.out.print(myList[i] + " ");
  23.         }
  24.  
  25.         Scanner keyboard = new Scanner(System.in);
  26.  
  27.  
  28.         System.out.println();
  29.         System.out.println("\nValue to find: ");
  30.         int arrayChosen = keyboard.nextInt();
  31.  
  32.         for (int i = 0; i < myList.length; i++) {
  33.             if (myList[i] == arrayChosen) {
  34.                 System.out.println(arrayChosen + " is in the array");
  35.  
  36.  
  37.                 System.out.print("Second Array: ");
  38.                 for (int e = 0; e < my2List.length; e++) {
  39.                     my2List[e] = 1 + rand.nextInt(50);
  40.                     System.out.print(my2List[e] + " ");
  41.                 }
  42.             }
  43.         }
  44.  
  45.  
  46.         System.out.println();
  47.         System.out.println("\nValue to find: ");
  48.         int array2Chosen = keyboard.nextInt();
  49.  
  50.         for (int e = 0; e < myList.length; e++) {
  51.             if (my2List[e] == array2Chosen) {
  52.                 System.out.println(array2Chosen + " is in the array");
  53.             }
  54.         }
  55.  
  56.  
  57.         System.out.print("Third Array: ");
  58.         for (int y = 0; y < my3List.length; y++) {
  59.             my3List[y] = 1 + rand.nextInt(50);
  60.             System.out.print(my3List[y] + " ");
  61.         }
  62.  
  63.         System.out.println();
  64.         System.out.println("\nValue to find: ");
  65.         int array3chosen = keyboard.nextInt();
  66.  
  67.         for (int z = 0; z < my3List.length; z++) {
  68.             if (my3List[z] == array3chosen) {
  69.                 System.out.println(array3chosen + " is in the array");
  70.             }
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement