hpilo

Chapter5_Arrays_Ex2

Dec 15th, 2018
103
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.80 KB | None | 0 0
  1. import java.util.Scanner;
  2. /*
  3. =====================================================
  4. chapter 5: Arrays
  5.  
  6. Ex2: ascending Array
  7. =====================================================
  8. */
  9.  
  10. public class MyProgram {
  11. public static void main(String[] args) {
  12. final int SIZE=5;
  13. int arr[]=new int[SIZE];
  14. boolean isSequence =true;
  15. Scanner s=new Scanner(System.in);
  16.  
  17. for(int i=0;i<arr.length;i++){
  18. arr[i]=s.nextInt();
  19. }
  20.  
  21. for(int i=1;i<arr.length;i++){
  22. if(arr[i-1]>=arr[i]){
  23. System.out.println("NOT Sequence");
  24. isSequence=false;
  25. break;
  26. }
  27.  
  28. }
  29. if(isSequence)
  30. System.out.println("Sequenced Array!");
  31. }
  32. }
Advertisement
Add Comment
Please, Sign In to add comment