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]
3 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]3 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:

meriva3 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
Using complete sentences post a detailed response to the following.
laiz [17]

Answer:

some advantages of top down is that you can start off from what you know and figure out what you need to complete it, advantages to bottom up is that you can make something new . if you are starting something from scratch and you dont know what the end goal might be you would use bottom up but if you already have an idea or the final product of what you want you would go the top down approach.

Explanation: just saying you shouldnt just copy and paste my response but rather pick out what you want to say and use this to complete what ever your working on. hope i helped :)

6 0
2 years ago
Read 2 more answers
Question 10 of 10
ValentinkaMS [17]

Answer:

C. Dow Jones

Explanation:

It’s the Dow Jones certainly, and we also know it as Dow 30. You will find with a little research that Dow Jones is an index of the 30 carefully chosen blue-chip stocks, and general industrial stocks. And this is price prejudiced average, and of 30 stocks that can be well-thought-out as an all-purpose measure for the whole stock market performance.

3 0
3 years ago
Which statement describes what the Conditional Formatting option in Excel 2016 allows users to do?
jeyben [28]

Answer:

It automatically applies formatting based on specific rules or conditions being met. It automatically applies highlighting to selected cell ranges based on specific rules or conditions being met.

Explanation:

6 0
3 years ago
Read 2 more answers
Write a program that asks the user to enter a number of seconds. There are 60 seconds in a minute. If the number of seconds ente
frez [133]

Answer:

// here is code in c.

#include <stdio.h>

// main function

int main()

{

// variable to store seconds

long long int second;

printf("enter seconds:");

// read the seconds

scanf("%lld",&second);

// if seconds is in between 60 and 3600

if(second>=60&& second<3600)

{

// find the minutes

int min=second/60;

printf("there are %d minutes in %lld seconds.",min,second);

}

// if seconds is in between 3600 and 86400

else if(second>=3600&&second<86400)

{

// find the hours

int hours=second/3600;

printf("there are %d minutes in %lld seconds.",hours,second);

}

// if seconds is greater than 86400

else if(second>86400)

{

// find the days

int days=second/86400;

printf("there are %d minutes in %lld seconds.",days,second);

}

return 0;

}

Explanation:

Read the seconds from user.If the seconds is in between 60 and 3600 then find the minutes by dividing seconds with 60 and print it.If seconds if in between 3600 and 86400 then find the hours by dividing second with 3600 and print it. If the seconds is greater than 86400 then find the days by dividing it with 86400 and print it.

Output:

enter seconds:89

there are 1 minutes in 89 seconds.

enter seconds:890000

there are 10 days in 890000 seconds.

8 0
2 years ago
What is the function of ctrl+Q​
vlabodo [156]

Answer:

Ctrl+Q is used to remove a paragraph's formatting

Explanation:

Hope that's the answer you're looking for!

5 0
2 years ago
Other questions:
  • Match the following.
    8·2 answers
  • Which of the following describes the difference in light intensity between the brightest white and the darkest black that can be
    15·1 answer
  • A style manual can be described as
    11·2 answers
  • Which of these trade-offs occur in a memory hierarchy?
    15·1 answer
  • Write 3 things that can't be done without technology. write your opinion?
    14·2 answers
  • You implement basic version control and go through the phase of creating a local repository. Initiate the commands to set up tha
    7·1 answer
  • The sameNumber method checks to see if the number of words in the phrase, numwords, is the same number of words contained in the
    5·1 answer
  • Adam has designed and tested an Android app for a startup. The client expects to get quick responses to the app. After consultin
    7·1 answer
  • Instruction: Decide what the total marketing budget will be, and make a list of at least four things you will spend money on and
    15·1 answer
  • 6. Write a C++ program to print the largest three elements in an array. <br>​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!