school/elements-in-range/LabProgram.java
2020-11-11 08:47:37 -05:00

45 lines
900 B
Java

/*
* Joseph Green
* 07-Oct-2020
*
* list of ints from input
*
* first int describes how many ints follow
*
* assume less than 20
*
* two more ints that describe lower and upper bounds of a range
*
* inclusevely print all numbers in the list from that range
*
* each output followed by space, even the last
*/
import java.util.Scanner;
public class LabProgram {
public static void main(String[] args) {
/* Type your code here. */
Scanner scnr = new Scanner(System.in);
int totalInts;
int max;
int min;
int[] ints = new int[20];
totalInts = scnr.nextInt();
for (int i =0; i<totalInts;i++){
ints[i] = scnr.nextInt();
}
min = scnr.nextInt();
max = scnr.nextInt();
for (int i =0; i<totalInts;i++){
if (ints[i] >= min && ints[i] <= max){
System.out.print(ints[i] + " ");
}
}
System.out.println();
}
}