Advertisement
Guest User

Untitled

a guest
Sep 25th, 2017
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.53 KB | None | 0 0
  1. import javax.swing.JOptionPane;
  2. public class ArrayChallenge{
  3. public static void main (String[] args){
  4. int input = Integer.parseInt(JOptionPane.showInputDialog("Guess the number of numbers."));
  5.  
  6. int[] arr = {3, 2, 1, 3, 8, 8, 1, 3, 2,};
  7.  
  8. int counter = 0;
  9.  
  10. for(int i = 0; i < arr.length; i++) {
  11.  
  12. if(input == arr[i]){
  13. counter++;
  14. }
  15. }
  16.  
  17. JOptionPane.showMessageDialog(null, "There were "+ counter + " of the number " + input);
  18. }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement