Advertisement
IanO-B

Untitled

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