daily pastebin goal
34%
SHARE
TWEET

Untitled

a guest Jan 17th, 2019 65 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import java.util.Scanner;
  2.  
  3. public class arraychecknumber
  4. {
  5.     public static void main(String[] args)
  6.     {
  7.         int[] previous = new int[4];
  8.         Scanner scan = new Scanner(System.in);
  9.        
  10.         for (int i = 0; i < 5; i++) {
  11.             int num;
  12.            
  13.             do {
  14.                 System.out.println("Enter a number between 10 and 100:");
  15.                 num = scan.nextInt();
  16.            
  17.                 if (num>100 || num < 10)
  18.                     System.out.println("Your number is not within 10 and 100, retry");
  19.             }while (num>100 || num<10);
  20.            
  21.             int k;
  22.                 for (k = 0; k < i; k++) {
  23.                     if (num == previous[k]) {
  24.                         System.out.println("Entered a duplicate number ");
  25.                         break;}
  26.                 }
  27.                
  28.                
  29.  
  30.             if (k == i)
  31.                 System.out.println("The number you entered: " + num);
  32.  
  33.             if (i < 4)
  34.                 previous[i]=num;
  35.             }
  36.     }
  37. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top