Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import javax.swing.JOptionPane;
- public class ArrayChallenge{
- public static void main (String[] args){
- int input = Integer.parseInt(JOptionPane.showInputDialog("Guess the number of numbers."));
- int[] arr = {3, 2, 1, 3, 8, 8, 1, 3, 2,};
- int counter = 0;
- for(int i = 0; i < arr.length; i++) {
- if(input == arr[i]){
- counter++;
- }
- }
- JOptionPane.showMessageDialog(null, "There were "+ counter + " of the number " + input);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement