1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Katyanochek1 [597]
4 years ago
13

Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integer

s that follow. Assume that the list will always contain less than 20 integers.
That list is followed by two more integers representing lower and upper bounds of a range. Your program should output all integers from the list that are within that range (inclusive of the bounds). For coding simplicity, follow each output integer by a space, even the last one.

Ex: If the input is:

5 25 51 0 200 33
0 50
then the output is:

25 0 33
(the bounds are 0-50, so 51 and 200 are out of range and thus not output).

To achieve the above, first read the list of integers into an array.
Computers and Technology
2 answers:
Xelga [282]4 years ago
7 0

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!

Download java
Tema [17]4 years ago
3 0

Answer:

integers=[]

while True:

      number=int(input())

      if number<0:

       break

      integers.append(number)  

print("",min(integers))

print("",max(integers))

Explanation:

You might be interested in
What is a risk or an effect of software piracy?
Butoxors [25]
Piracy is a term used to describe the practice of obtaining or using software in a manner that is illegal or not in keeping with the terms under which the software was distributed. This can range from purchasing or copying the software, to using the software without a license, to selling, renting, or otherwise distributing it without authorization.<span>The Business Software Alliance estimated the losses to software companies in 2005 as a result of piracy at over $30 billion.</span>
5 0
4 years ago
Read 2 more answers
What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from r
mixer [17]

Answer:

What is the shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise)? - sll$t0, $t3, 9# shift $t3 left by 9, store in $t0

srl $t0, $t0, 15# shift $t0 right by 15

Explanation:

The shortest sequence of MIPS instructions that extracts a field for the constant values of bits 7-21 (inclusive) from register $t0 and places it in the lower order portion of register $t3 (zero filled otherwise) is shown below:

sll$t0, $t3, 9# shift $t3 left by 9, store in $t0

srl $t0, $t0, 15# shift $t0 right by 15

4 0
3 years ago
Identify the command on a local desktop CMD that will verify which group policies have been applied to the workstation. SELECT T
fomenos

Answer:

The answer is gpupdate

Explanation:

gpupdate command is used to update Group policies in Windows operating system Domain.

There are different options to use with the gpupdate but one of the most used option is the '/force' which will reapply all policy settings

8 0
3 years ago
Which theorist studied the power elite and the influence they had over society?
Pavel [41]
The correct answer is <span>C. Wright Mills
He was a rather famous sociologist from the 20th century who also worked as a professor at Columbia university. He was a leftist and one of his famous books "The Power Elite" was crucial in describing class relations in the US between the elites and the regular people.</span>
6 0
3 years ago
Match the instruments with their uses.
Aneli [31]
Microscope - 1
Telescope - 2
Ruler - 3
Streak plate - 4

7 0
3 years ago
Read 2 more answers
Other questions:
  • Why do bullies and criminals often say things online they otherwise wouldn’t say
    9·2 answers
  • Ken has inserted an image into his PowerPoint presentation, but the image contains a lot of empty and/or unnecessary space. He n
    10·1 answer
  • While working on a group project, you notice something does not look right in the presentation. You call a meeting with your tea
    14·2 answers
  • By default, server manager does not connect with down-level servers (for example, windows server 2008). what must be done to pro
    13·1 answer
  • Why information technology is important in healthcare?
    13·1 answer
  • The commands available from a menu change depending upon what you are doing.<br> True<br> False
    11·2 answers
  • What are the advantages of Napier bones?​
    15·1 answer
  • All the network nodes are connected to each other
    8·1 answer
  • Computer applications
    9·1 answer
  • // This pseudocode segment is intended to compute the number
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!