Advertisement
N3ggg

Untitled

Feb 26th, 2020
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. import java.util.*;
  2. public class Main {
  3.  
  4. public static void main(String[] args) {
  5. Scanner keyboard = new Scanner(System.in);
  6. int[] a = new int[10];
  7. Random r = new Random();
  8. System.out.print("Array: ");
  9. for (int i = 0; i < a.length; i++) {
  10. a[i] = 1 + r.nextInt(50);
  11. System.out.print(a[i] + " ");
  12. }
  13. System.out.println();
  14. System.out.print("Value to find: ");
  15. int choice = keyboard.nextInt();
  16. System.out.println();
  17. for (int i = 0; i < a.length; i++) {
  18. if (a[i] == choice) {
  19. System.out.println(choice + " is in the array.");
  20. }
  21. }
  22. }
  23. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement