Respuesta :
Answer:
import java.util.Scanner;
public class ListOfIntegers {
public static void main(String[] args) {
// Create an object of the Scanner class to allow for user input
Scanner input = new Scanner(System.in);
// Prompt the user for the number of integers they want to enter
System.out.print("Enter the number of integers : ");
// Get and store the number of integers entered by user
int n = input.nextInt();
System.out.println();
// Create an array to hold the integers
// The array has the same length as the number of integers
int[] numbers = new int[n];
// Create a loop that asks the user to enter all integers
// At each cycle of the loop, save the entered integer into the array
for (int i = 0; i < n; i++) {
System.out.print("Enter number " + (i + 1) + " : ");
numbers[i] = input.nextInt();
System.out.println();
}
// Prompt the user for the lower bound
System.out.print("Enter the lower bound : ");
// Get and store the lower bound in a variable
int lowerbound = input.nextInt();
System.out.println();
// Prompt the user for the upper bound
System.out.print("Enter the upper bound : ");
// Get and store the upper bound in a variable
int upperbound = input.nextInt();
System.out.println();
System.out.println("OUTPUT :: ");
// Create a loop to cycle through the array of numbers.
// At each cycle, check if the array element is within range.
// If it is within range, print it to the console
for (int j = 0; j < numbers.length; j++) {
if (numbers[j] >= lowerbound && numbers[j] <= upperbound) {
System.out.print(numbers[j] + " ");
}
}
}
}
Explanation:
Please go through the comments in the code for more readability and understanding. The source code file has been attached to this response. Kindly download the file to get a better formatting of the code.
Hope this helps!
Answer:
integers=[]
while True:
number=int(input())
if number<0:
break
integers.append(number)
print("",min(integers))
print("",max(integers))
Explanation: