Advertisement
Guest User

Untitled

a guest
Mar 20th, 2019
106
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. double[] aboveLimit = new double[list2.length];
  2. double limit; //set limit variable
  3. int j = 0;
  4. for(int i = 0;i < list2.length;i++) {
  5. if(list2[i] > limit) {
  6. aboveLimit[j] = list2[i];
  7. j++;
  8. }
  9. }
  10.  
  11. for(int i = 0;i < aboveLimit.length;i++) { //checks when reached end of all numbers
  12. if(aboveLimit[i] == 0) {
  13. if(i == 0) {
  14. break; //if there are no numebrs greater than the limit, nothing happens
  15. }
  16. else {
  17. System.out.println(" are above the limit.");
  18. break;
  19. }
  20. }
  21. else {
  22. System.out.println(aboveLimit[i] + ", ");
  23. }
  24. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement