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]
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
Write a program that calculates an adult's fat-burning heart rate, which is 70% of 220 minus the person's age. Complete fat_burn
gayaneshka [121]

Answer:

#include <iostream>

# include <conio.h>

using namespace std;

float fat_burning_heart_rate(float age);

main()

{

float age,bpm;

cout<<"enter the age of the person"<<endl;

cin>>age;

if (age>=18 && age<=75)

{

bpm=fat_burning_heart_rate(age);

cout<<"fat burning heart rate for the age of"<<age<<"="<<bpm;

}

else

cout<<"Invalid age";

getch();

}

float fat_burning_heart_rate(float age)

{

 

float a;

 

a= (220-age)*0.7;

return a;

}

Explanation:

In this program, the variable named as age has been taken to enter the age of the person, needs to calculate the burning heart rate. All the variables taken in float, as the age and fat burning heart rate should come in decimal value.

The formula has been used as mention in question that,

a= (220-age)*0.7;

8 0
2 years ago
Given three floating-point numbers x, y, and z, output x to the power of y, x to the power of (y to the power of z), the absolut
Angelina_Jolie [31]

Answer:

float x

float y

float z

x = Get next input

y = Get next input

z = Get next input

Put RaiseToPower(x, y) to output

Put "\n" to output

Put RaiseToPower(x, RaiseToPower(y, z)) to output

Put "\n" to output

Put AbsoluteValue(x) to output

Put "\n" to output

Put SquareRoot(RaiseToPower(x*y, z)) to output

Explanation:

The first three lines of code is simply declaring the data type of the x, y and z variables which was declared as float type meaning number with decimal points.

The next three lines after the first three lines is getting the input from the user

In coral, we use Put <expression> to output to display <expression> to the console

For the first Put statement, I am telling the interpreter to display the value of x raised to the power of y to the console by using Coral's RaiseToPower built-in math function

The Put "\n" to output statement scattered in the snippet is just for formatting reasons so that each result will be displayed in a newline

The next computation RaiseToPower(x, RaiseToPower(y, z)) is a bit nested but  it is actually doing this: x^{y^{z} }

The next computation is AbsoluteValue(x) is doing this |x|

And the final computation SquareRoot(RaiseToPower(x*y, z)) is doing this:

\sqrt{(xy)^{z} }

3 0
2 years ago
Consider a DHT with a mesh overlay topology (that is, every peer tracks all peers in the system). What are the advantages and di
Vladimir79 [104]

Answer:

Advantages of DHT with mesh overlay topology

  • A single hop is used to route a message to the peer, the nearest key is used route message between points
  • There are  bi-directional links between each pair of peers other than the broadcasting peer therefore creating a multiple delivery paths from source to other peers

Disadvantages of DHT with mesh overlay topology

  • complexity of the design of a Mesh overlay Topology
  • Consuming process ( tracking of all peers by each peer )

Advantages of circular DHT ( with no shortcuts )

  • less consuming process ( each peer tracks only two peers )

Disadvantages of Circular DHT ( with no short cuts )

  • The number of messages sent per query is minimized
  • 0(N) hopes are required to route message to a peer responsible for the key  

Explanation:

Advantages of DHT with mesh overlay topology

  • A single hop is used to route a message to the peer, the nearest key is used route message between points
  • There are  bi-directional links between each pair of peers other than the broadcasting peer therefore creating a multiple delivery paths from source to other peers

Disadvantages of DHT with mesh overlay topology

  • complexity of the design of a Mesh overlay Topology
  • Consuming process ( tracking of all peers by each peer )

Advantages of circular DHT ( with no shortcuts )

  • less consuming process ( each peer tracks only two peers )

Disadvantages of Circular DHT ( with no short cuts )

  • The number of messages sent per query is minimized
  • 0(N) hopes are required to route message to a peer responsible for the key  

Distributed hash table (DHT) is a distributed system that provides a lookup service similar to a hash table. in the DHT key-value are stored in it

6 0
2 years ago
Which of the following, (1) money deposited in a bank account, (2) student recording her answer to a question in an online test,
Minchanka [31]

Answer:

The answer is "Option c"

Explanation:

In the computer system, it describes and arranges the dataset and analyses it. This system is intended to make raw information useful.

  • This information can be used in an organization for decision-making.  
  • There are many types of software (shopping, record managing, and bank app), that can store information, that's why all except "option c" all were wrong.
8 0
2 years ago
Write a class named Taxicab that has three **private** data members: one that holds the current x-coordinate, one that holds the
Licemer1 [7]

Answer:

See explaination

Explanation:

class Taxicab():

def __init__(self, x, y):

self.x_coordinate = x

self.y_coordinate = y

self.odometer = 0

def get_x_coord(self):

return self.x_coordinate

def get_y_coord(self):

return self.y_coordinate

def get_odometer(self):

return self.odometer

def move_x(self, distance):

self.x_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

def move_y(self, distance):

self.y_coordinate += distance

# add the absolute distance to odometer

self.odometer += abs(distance)

cab = Taxicab(5,-8)

cab.move_x(3)

cab.move_y(-4)

cab.move_x(-1)

print(cab.odometer) # will print 8 3+4+1 = 8

7 0
2 years ago
Other questions:
  • Janice usually works on a particular workbook. She decides to keep a backup of all the data in a separate workbook. She opens a
    6·2 answers
  • Describe the Say It, Cover It, Resay It method.
    14·2 answers
  • Explain why the cost of ownership may be lower with a cloud database than with a traditional, company database.
    9·1 answer
  • While trying to solve a network issue, a technician made multiple changes to the current router configuration file. The changes
    7·1 answer
  • This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance
    5·1 answer
  • Anime question where do i watch Itadaki! Seieki! 100 points
    15·2 answers
  • Consider the following class definitions.
    10·1 answer
  • There is a function we are providing in for you in this problem called square. It takes one integer and returns the square of th
    9·1 answer
  • 2.32 LAB: Musical note frequencies On a piano, a key has a frequency, say f0. Each higher key (black or white) has a frequency o
    13·1 answer
  • Write a cout statement that prints the value of a conditional expression. The conditional expression should determine whether th
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!