Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- double[] aboveLimit = new double[list2.length];
- double limit; //set limit variable
- int j = 0;
- for(int i = 0;i < list2.length;i++) {
- if(list2[i] > limit) {
- aboveLimit[j] = list2[i];
- j++;
- }
- }
- for(int i = 0;i < aboveLimit.length;i++) { //checks when reached end of all numbers
- if(aboveLimit[i] == 0) {
- if(i == 0) {
- break; //if there are no numebrs greater than the limit, nothing happens
- }
- else {
- System.out.println(" are above the limit.");
- break;
- }
- }
- else {
- System.out.println(aboveLimit[i] + ", ");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement