answer.
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]
1 year 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]1 year 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:

meriva1 year 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
Assume that name has been declared suitably for storing names (like "Misha", "Emily" and "Sofia") Write some code that reads a v
dlinn [17]

Answer:

void main(){

string name;

cout<<"Enter Name";

cin>>name;

cout<<"Greetings   " ;

cout<<name;

}

Explanation:

in main function we declared a variable called "name" .using cin we are reading the value into name  and we are printing that name using  cout.

3 0
2 years ago
If a car's is malfunctioning, people in the car will become ill when driving long distances, especially if the windows are close
galben [10]
The Carbon Monoxide will build up in the inside of the car by venting through, causing the passengers to breathe it. It will first make them ill, then kill them. They cannot detect this gas
5 0
2 years ago
Read 2 more answers
Which method allows a computer to react accordingly when it requests data from a server and the server takes too long to respond
Rina8888 [55]

Answer:

A. Request timeout.

Explanation:

The end devices like the computer systems in a network seeks to share resources with one another and/ or request resources from central server.

With this, there are two ways computers in a network can communicate. They are peer to peer network communication and client-server network communication.

The client-server communication requires a dedicated central server where computers in the network require data. Peer to peer describes a network where computers serve as both client and server to each other.

Request timeout is a message sent to a source when the time to live period (TTL) of a packet expires.

6 0
2 years ago
What is a key differentiator of Conversational AI? It implements Natural Language Understanding (NLU) and other human-like behav
Pavel [41]

Answer:

c

Explanation:

4 0
2 years ago
Which of the following is an advantage of inserting a page number field in your document rather than inserting each page number
Artyom0805 [142]

The advantage of inserting the page number field is that the page number field could show the current page number.

The following information should be relevant with respect to the page number:

  • The page number field & the actual page number should be formatted.
  • The page number field & the actual page number both could be inserted into the header or footer.
  • The page number field & the actual page number could be easily inserted into the document.

Therefore we can conclude that the advantage of inserting the page number field is that the page number field could show the current page number.

Learn more about the page number here: brainly.com/question/3063419

8 0
1 year ago
Other questions:
  • Where is the Name Manager dialog box found?
    13·1 answer
  • Which computer applications can Mr. Crowell use to make the classroom learning more stimulating and interesting? Mr. Crowell has
    9·2 answers
  • The ________ utility automatically creates duplicates of your libraries, desktops, contacts, and favorites to another storage lo
    6·1 answer
  • A slide in Blake's presentation contained the following information:
    11·1 answer
  • Define a method printFeetInchShort, with int parameters numFeet and numInches, that prints using ' and " shorthand. End with a n
    7·2 answers
  • A spreadsheet keeps track of student scores on all the exams in a course. Each row of the spreadsheet corresponds to one student
    14·1 answer
  • As a digital forensics examiner, it’s a good idea to build a list of references for information on privacy laws in other countri
    13·1 answer
  • What is the average number of nodes accessed in search for a particular element in an unordered list? In an ordered list? In an
    6·1 answer
  • [20 points] 3.3 Code Practice: Question 2
    7·1 answer
  • 3. Write a program to find the area of a triangle using functions. a. Write a function getData() for user to input the length an
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!