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
frosja888 [35]
2 years ago
12

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. Then, get the last value from the input, which indicates a threshold. Output all integers less than or equal to that last threshold value.
Computers and Technology
2 answers:
Dafna11 [192]2 years ago
4 0

Answer:

def output_ints_less_than_or_equal_to_threshold(user_values, upper_threshold):

 for value in user_values:

     if value < upper_threshold:

         print(value)  

def get_user_values():

 n = int(input())

 lst = []

 for i in range(n):

     lst.append(int(input()))

 return lst  

if __name__ == '__main__':

 userValues = get_user_values()

 upperThreshold = int(input())

 output_ints_less_than_or_equal_to_threshold(userValues, upperThreshold)

Explanation:

meriva2 years ago
3 0

Answer:

package b4;

import java.util.Scanner;

public class TresholdValue {

public static void main(String[] args) {

 // Create an object of the Scanner class to allow for user's input

 Scanner input = new Scanner(System.in);

 // Create a prompt to allow users to enter the set of integers

 System.out.println("Please enter the set of integers, each followed by a space : ");

 // Get the first integer from the set of inputs.

 // Parse the input and convert it into an integer

 // by using the Integer.parseInt() method.

 // Store the result in an integer variable.

 int first = Integer.parseInt(input.next());

 // Create an integer array to hold the other numbers (first number excluded).

 // The array should have a length equal in value to the first number in the set.

 // This has been stored in a variable called "first".

 int[] intarray = new int[first];

 // Create a while loop that populate the intarray with the set of numbers

 int i = 0;

 while (input.hasNext() && i < intarray.length) {

  intarray[i] = Integer.parseInt(input.next());

  i++;

 }

 // Get the last value (threshold) from the intarray.

 // The threshold value is the last element in the array.

 int lastvalue = intarray[intarray.length - 1];

 // Create a prompt before displaying the set of values that are less than or

 // equal to the threshold value.

 System.out.println("Values less than or equal to the threshold value (" + lastvalue + ") are : ");

 // Create a loop to cycle through the array.

 // At each cycle, the element is checked if or not it is less than or equal to

 // the threshold value.

 // If it is less than or equal to, the number is printed.

 for (int j = 0; j < intarray.length - 1; j++) {

  if (intarray[j] <= lastvalue) {

   System.out.print(intarray[j] + " ");

  }

 }

 // (Optional) Close the Scanner object to prevent resource leak

 input.close();

}

}

Explanation:

The program has been written in Java. The source code file has been attached to this response. Please download it for better readability. The code contains comments explaining what goes on on each segment of the code.

Hope this helps!

Download java
You might be interested in
.....is used to save project in Visual basic .net from file menu
Harlamova29_29 [7]

Explanation:

I don't really understand what you're trying to get at, maybe try to abbreviate a little more?

4 0
3 years ago
This sensor is used for burglar alarms<br>A. temperature<br>b. humidity<br>c. movement<br>d. PH​
bogdanovich [222]

Answer:

C

Explanation:

Have a great summer :)

8 0
3 years ago
Should Gladys call the legal authorities? Which agency should she call?
tiny-mole [99]

Answer:

The answer to this question can be defined as below:

Explanation:

Yes, Gladys is called the legal authority. In the whole situation, legal officials can be concerned, even though the situation can proceed to fraud. Then it will be acceptable to make a report to the Justice Department.

  • In a corporation, it should always tend to avoid the issue, like leaking information, leaking the glamorous info to the press.
  • They may have a contract within the organization to avoid all of this.
3 0
3 years ago
What is the first thing you should do to find a mean and range of data?
KatRina [158]

Answer

To find mean of data add all the numbers in the set of data and divide the sum by the number of addends.

To find range, identify the difference between the highest value and lowest value in the set of data.

Explanation

Mean, mode, median and range are the primary measurements used to get the measures of central tendencies. To get the mean and range; first arrange the data in an ascending order, then identify the highest value and the lowest value in the set. The difference between these two data values gives the range of the set of values. For the mean, add all the set of values and then divide their sum with the number of values in the set of data.


6 0
3 years ago
Synthesizing information can be done by creating
Maurinko [17]

Answer:

D

Explanation:

because you use all of those

4 0
3 years ago
Read 2 more answers
Other questions:
  • In a word processing program, the ribbon or menus contain the
    12·1 answer
  • What would I need to make the perfect music video
    10·1 answer
  • What is an independent data mart?
    8·1 answer
  • Word 2013 in order to share a document online you must first
    10·1 answer
  • Find the word-length 2's complement representation of each of the following decimal numbers:a. 845b. 15000c. 100d. -923
    8·2 answers
  • ITS MAKING ME TYPE URL CODES NOW!
    6·1 answer
  • How can i address inv file in c for open it?
    13·1 answer
  • a bus is full of passengers. if you count them by either twos, threes, or fives, there is one left. if you count them by seven t
    10·1 answer
  • Yaaaaaa.........
    7·2 answers
  • This might sound crazy! But please help.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!