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
mote1985 [20]
3 years ago
15

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. Assume that the list will always contain fewer than 20 integers.
Ex: If the input is
5 50 60 140 200 75 100

the output is
50 60 75
Computers and Technology
1 answer:
Gre4nikov [31]3 years ago
7 0

Answer:

The program in Python is as follows:

num = int(input())

numList = []

for i in range(num+1):

   numInput = int(input())

   numList.append(numInput)

for i in range(len(numList)-1):

   if numList[i] <= numList[-1]:

       print(numList[i],end=" ")

Explanation:

This gets input for the number of integers

num = int(input())

This initializes an empty list

numList = []

This iterates through the number of integers and gets input for each

for i in range(num+1):

   numInput = int(input())

The inputs including the threshold are appended to the list

   numList.append(numInput)

This iterates through the list

for i in range(len(numList)-1):

All inputs less than or equal to the threshold are printed

   if numList[i] <= numList[-1]:

       print(numList[i],end=" ")

You might be interested in
Which of the following statements about functional programming languages is incorrect?A) In pure functional programming, there a
omeli [17]
The answer is (C)
In pure functional programming loops are replaced by recursive calls
3 0
3 years ago
When a router fails to send messages in a timely fashion, this is a problem of the _____.
natima [27]
<span>network layer  

hope it helped</span>
4 0
3 years ago
What needs to be done before depositing a check using a mobile app?
galben [10]

Answer:

The check needs to be signed in the back by you or whoever is depositing it.

7 0
2 years ago
Read 2 more answers
Write a program to help a travelling sales person keep up with their daily mileage driven for business. In your main method, the
Lelu [443]

Answer:

The programming language is not stated;

<em>The program written in C++ is as follows (See Explanation Section for detailed explanation);</em>

#include<iostream>

using namespace std;

int main()

{

 int numdays;

 cout<<"Number of days of mileage: ";

 cin>>numdays;

 int miles[numdays];

for(int i=0;i<numdays;i++)

{

 cout<<"Miles traveled on day "<<i+1<<": ";

 cin>>miles[i];

}

 int total = 0;

 for(int i=0;i<numdays;i++)

{

 total+=miles[i];

}

cout<<"Total mileage traveled: "<<total;

 return 0;

}

Explanation:

This line declares the number of days of mileage

 int numdays;

This line prompts user for days of mileage

 cout<<"Number of days of mileage: ";

This line accepts input from the traveler for days of mileage

 cin>>numdays;

This line creates an array

 int miles[numdays];

The italicized is an iteration that collects the user input for each day

<em> for(int i=0;i<numdays;i++)</em>

<em> {</em>

<em>  cout<<"Miles traveled on day "<<i+1<<": ";</em>

<em>  cin>>miles[i];</em>

<em> }</em>

This line initializes variable to 0

 int total = 0;

The italicized is an iteration that adds up the mileage traveled by the traveler each day  

<em>  for(int i=0;i<numdays;i++)</em>

<em> {</em>

<em>  total+=miles[i];</em>

<em> }</em>

This line prints the total miles traveled

cout<<"Total mileage traveled: "<<total;

5 0
4 years ago
Assume that the int variables i, j and n have been declared , and n has been initialized . write code that causes a "triangle" o
SIZIF [17.4K]

Here you go,

class Program

   {

       static void Main(string[] args)

       {          

          int n,i,j;

          Console.Write("Enter size: ");

          n = Convert.ToInt32(Console.ReadLine());

          for (i = 1; i <= n; i++)

          {

              for (j = 1; j <= i; j++)

              {

                  System.Console.Write("*");

              }

              System.Console.Write("\n");

          }          

           Console.ReadLine();

       }

   }

5 0
3 years ago
Other questions:
  • 2 Which statement best explains how computers are used to analyze information?
    6·1 answer
  • which of the following is not an operating system? A. leopard B. linux C. firefox D. windows
    11·2 answers
  • Local variables:
    7·1 answer
  • Use the image above to determine which toolbars will be displayed in the program you are using. SELECT ALL THAT APPLY
    11·2 answers
  • Your boss asks you to transmit a small file that includes sensitive personnel data to a server on the network. the server is run
    6·1 answer
  • Give an example of an outdated memory or storage device what do you think they are outdated
    12·1 answer
  • 2. Write a program with a function that accepts a string as an argument and returns a copy of the string with the first characte
    11·1 answer
  • How will you ensure that all of the network's applications and tcp/ip services also support ipv6?
    10·1 answer
  • What is the purpose of a router
    13·2 answers
  • how does the use of data abstraction manage complexity in program code? how does using lists make a program easier to develop an
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!