Respuesta :
Answer:
Explanation:
The following is coded in Java. It asks the user for the number of inputs and then creates a loop to read all of the inputs and adds them to an ArrayList. Then it saves the last value in the array as the threshold. Finally, it loops through the array printing only the values less than or equal to the threshold. The program has been tested and the output can be seen in the image below.
import java.util.ArrayList;
import java.util.Scanner;
class Brainly {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
ArrayList<Integer> myList = new ArrayList<>();
System.out.println("How many inputs will you add? ");
int inputs = in.nextInt();
System.out.println("Enter inputs: ");
for (int i = 0; i< inputs; i++) {
int num = in.nextInt();
myList.add(num);
}
int threshold = myList.get(myList.size()-1);
System.out.println("Inputs Less than or Equal to Threshold: ");
for (int x: myList) {
if (x <= threshold) {
System.out.println(x);
}
}
}
}
