Advertisement
Guest User

Untitled

a guest
Apr 24th, 2017
52
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. import java.util.*;
  2. import java.io.* ;
  3.  
  4.  
  5. public class Lab8Part6 {
  6. public static void main(String[] args) {
  7. double[] a1 = {16.1, 25.3, 12.2, 44.4};
  8. double[] a2 = {1.5, 4.3, 7.0, 19.5, 25.1,
  9. 46.2};
  10. double[] a3 = {42.0};
  11. System.out.println(isSorted(a1)); // false
  12. System.out.println(isSorted(a2)); // true
  13. System.out.println(isSorted(a3)); // true
  14. }
  15.  
  16. public static isSorted(double[] list){
  17. for (int i = 0; int i <= list.length-2; i++){
  18. if (list[i] > list[i+1] ){
  19. return false;
  20. break;
  21. }
  22. else{
  23. return true;
  24. }
  25. }
  26. }
  27.  
  28.  
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement