6.22 LAB: Output values below an amount - methods
Write a program that first gets a list of integers from input. The input begins with an integer indicating the number of integers that follow. Then, get the last value from the input, and output all integers less than or equal to that value. Assume that the list will always contain less than 20 integers.

Ex: If the input is:

5 50 60 140 200 75 100
the output is:

50 60 75
The 5 indicates that there are five integers in the list, namely 50, 60, 140, 200, and 75. The 100 indicates that the program should output all integers less than or equal to 100, so the program outputs 50, 60, and 75. For coding simplicity, follow every output value by a space, including the last one.

Such functionality is common on sites like Amazon, where a user can filter results.

Write your code to define and use two methods:
public static void getUserValues(int[] myArr, int arrSize, Scanner scnr)
public static void outputIntsLessThanOrEqualToThreshold(int[] userValues, int userValsSize, int upperThreshold)

Utilizing methods will help to make main() very clean and intuitive.


My Code & Error Message Attached
import java.util.Scanner;

public class LabProgram {

public static void GetUserValues(int[] myArr, int arrSize, Scanner scnr){
int i;
for(i=0;i myArr[i] = scnr.nextInt();
}
}

public static void outputIntsLessThanOrEqualToThreshold(int[] userValues, int userValsSize, int upperThreshold) {
int i;
for(i=0;i if(userValues[i] <= upperThreshold)
System.out.print(userValues[i]+" ");
}

}

public static void main(String[] args) {
Scanner scnr = new Scanner(System.in);
int[] userValues = new int[20];
int upperThreshold;
int numVals;

numVals = scnr.nextInt();
GetUserValues(userValues, numVals, scnr);

upperThreshold = scnr.nextInt();
outputIntsLessThanOrEqualToThreshold(userValues, numVals, upperThreshold);
System.out.println();

}
}

6.22 LAB: Output Values Below An Amount - MethodsWrite A Program That First Gets A List Of Integers From

Answers

Answer 1

Answer:

hope this helps.

Explanation:

n = int(input())

lst = []

for i in range(n):

lst.append(int(input()))

threshold = int(input())

for x in lst:

if x < threshold:

print(x)

Answer 2

Following are the Java program to find the less number from 100 in 5 number of the array:

Java Program to check array numbers:

please find the code file in the attachment.

Output:

Please find the attached file.

Program Explanation:

import package.Defining class LabProgram Inside the class two methods "GetmyArr, outputIntsLessThanOrEqualToThreshold"  is defined that takes three variable inside the parameters.In the "GetmyArr" method it takes one array and one integer variable and a scanner that inputs the array value "myArr" which limits set into the "arrSize" variable. In the "outputIntsLessThanOrEqualToThreshold" method it takes three parameters "myArr, arrSize, and upperThreshold". In this, it checks array value is less than "upperThreshold", and prints its value.Outside this main method is defined that defines array and variable and class the above method.

Find out more about the java code here:

brainly.com/question/5326314

6.22 LAB: Output Values Below An Amount - MethodsWrite A Program That First Gets A List Of Integers From
6.22 LAB: Output Values Below An Amount - MethodsWrite A Program That First Gets A List Of Integers From

Related Questions

Suppose a program is supposed to reverse an array. For example, if we have the array arr = {1, 2, 3, 4, 5}, after reversing the array we would have arr = {5, 4, 3, 2, 1}.

Most of the code for the program is shown here:
Const int SIZE = 5;
int arr[SIZE] = {1, 2, 3, 4, 5};
int firstindex =0, lastindex = SIZE-1, temp;

1 _______________________________

{
temp = arr[firstindex];
arr[firstindex] = arr[lastindex];
arr[lastindex] = temp;
firstindex++;
lastindex--;
}

All of the following options below could be correctly inserted at line 1 in the code shown above EXCEPT:

a. while(firstindex < lastindex)
b. while(firstindex <= lastindex)
c. for(int i=0; i<(SIZE/2-1); i++)
d. for(int i=0; i<(SIZE/2); i++)

Answers

Answer:

The answer is "Choice C".

Explanation:

In this question, the choice C is correct because all the other options will the output "5 4 3 2 1" and it will given "5 2 3 4 1" as output which is defined in the attached file. please find it.

Which of the following does PXE use?
a) USB
b) DVD-ROM
c) CD-ROM
d) NIC

Answers

Answer:

The answer is d) NIC.

Explanation:

PXE Stands for Preboot Execution Environment and a PXE uses an NIC also know as Network Interface Controller. For an example: If you have a DELL Inspiron 8500 and you couldn't get it to work you would need to go through all boot-up system including a Preboot Execution Environment in the booting code protocols it would say connecting to NIC after 6 seconds it would say NIC connected then it would search for a boot device after a few munities since the DELL Inspiron 8500 is obsolete you would get this message:

No Boot Device found

Ralph and his team need to work together on a project. If they need a device that will provide shared storage with access to all team members, which of these devices would work best? *

USB Flash Drive
2 TB HDD installed on one of their computers
BD-RW installed on one of their computers
Network attached storage appliance

Answers

You will need a network attached storage appliance

What transport layer protocol does DNS normally use?

Answers

Explanation:

DNS uses the User Datagram Protocol (UDP) on port 53 to serve DNS queries. UDP is preferred because it is fast and has low overhead. A DNS query is a single UDP request from the DNS client followed by a single UDP reply from the server.

The transport layer protocol that DNS normally use is the User Datagram Protocol (UDP).

What is transport layer protocol?

The Internet Protocol (IP) is a network layer protocol, and the Transmission Control Protocol (TCP) is a transport layer protocol.

A network communication between applications is established and maintained according to the Transmission Control Protocol (TCP) standard. The Internet Protocol (IP), which specifies how computers send data packets to one another, works with TCP.

User Datagram Protocol (UDP) on port 53 is how DNS serves DNS requests. Due to its speed and low overhead, UDP is recommended. A single UDP request from the DNS client and a single UDP response from the server makes up a DNS query.

Therefore, the transport layer protocol used by DNS is User Datagram Protocol (UDP).

To learn more about transport layer protocol, refer to the link:

https://brainly.com/question/4727073

#SPJ12

Consider the following method:
public static String joinTogether(int num, String[] arr)
{
String result = "";
for (String x : arr)
{
result = result + x.substring(0, num);
}
return result;
}

The following code appears in another method in the same class:
String[] words = {"dragon", "chicken", "gorilla"};
int number = 4;
System.out.println(joinTogether(number, words));

What is printed when the code above is executed?
a. dragonchickengorilla
b. drachigor
c. dragchicgori
d. dragochickgoril
e. There is an error in the program, it does not run

Answers

Answer: b.

Explanation:

Create a public class called Catcher that defines a single class method named catcher. catcher takes, as a single parameter, a Faulter that has a fault method. You should call that fault method. If it generates no exception, you should return 0. If it generates a null pointer exception, you should return 1. If it throws an illegal argument exception, you should return 2. If it creates an illegal state exception, you should return 3. If it generates an array index out of bounds exception, you should return 4.

Answers

Answer:

Sorry mate I tried but I got it wrong

Explanation:

Sorry again

BIOS programs are embedded on a chip called ​

Answers

Explanation:

BIOS software is stored on a non-volatile ROM chip on the motherboard.

1.   Microsoft Office is ?​

Answers

Answer:

What do you mean?

Explanation:

Microsoft office is a good tech company

I just the question what

StreamPal is an audio-streaming application for mobile devices that allows users to listen to streaming music and connect with other users who have similar taste in music. After downloading the application, each user creates a username, personal profile, and contact list of friends who also use the application.

The application uses the device’s GPS unit to track a user’s location. Each time a user listens to a song, the user can give it a rating from 0 to 5 stars. The user can access the following features for each song that the user has rated.

A list of users on the contact list who have given the song the same rating, with links to those users’ profiles
A map showing all other users in the area who have given the song the same rating, with links to those users’ profiles
A basic StreamPal account is free, but it displays advertisements that are based on data collected by the application. For example, if a user listens to a particular artist, the application may display an advertisement for concert tickets the next time the artist comes to the user’s city. Users have the ability to pay a monthly fee for a premium account, which removes advertisements from the application.

Which of the following statements is most likely true about the differences between the basic version and the premium version of StreamPal?

Group of answer choices
a. Users of the basic version of StreamPal use less data storage space on their devices than do users of the premium version of StreamPal.
b. Users of the basic version of StreamPal are more likely to give songs higher ratings than are users of the premium version of StreamPal.
c. Users of the basic version of StreamPal indirectly support StreamPal by allowing themselves to receive advertisements.
d. Users of the basic version of StreamPal spend more on monthly fees than do users of the premium version of StreamPal.

Answers

Answer:

Users of the application may have the ability to determine information about the locations of users that are not on their contact list.

What career opportunities are available within the floral industry?

Answers

Answer: The floral industry has quite an array of possible occupation pathways. You can do flower production, design, publishing, marketing, home design, engineering, retailing, commercial, research, and lots more.

how can a computer be used by a manager of a shopping mall​

Answers

Answer:

- used to look at security cameras

- used to buy supplies for the mall (maintenance)

- billing

Answer:

With growing square footage of shopping malls, however, comes the challenge of managing these super structures. Shopping mall managers need to take care of all tenant and building services, including physical security hardware of both the individual tenants’ spaces, the general facility and common areas.

What are some of the security and access control challenges unique to shopping centers and malls?

Multiple tenants across multiple buildings. Access for tenants with their own set of employees needs to be managed efficiently.

Tenant turnover.  When a tenant terminates his lease, his ability to access the space should be completely revoked.  Mall management must be able to do this in a timely manner for the security of the shared property and for the safety of the next tenant.

Expansion, reduction and relocation of tenants within facilities.  While this does not entail revocation of access, mall management must be able to provide smooth transition, in terms of access control to the new space, and denial of access to the previously-occupied space where a new tenant will be moving in.

Security for Shared Entrances and Spaces. Managing access privileges for shared facilities like that in a mall can be challenging. For instance, if a tenant in a mall hires or fires an employee, mall management needs to be informed so they can update access privileges to common entrances and shared spaces. This also applies for maintenance workers, cleaning crews and the like. An efficient access control system allows mall management to control access privileges with ease.

Explanation:

what was original name
whoever answers first gets brainly crown

Answers

Answer:

BackRub

Explanation:

what is java programing

Answers

Answer:

Explanation:

Java is a class-based, object-oriented programming language that is designed to have as few implementation dependencies as possible. ... Java applications are typically compiled to bytecode that can run on any Java virtual machine (JVM) regardless of the underlying computer architecture

Answer:

The Java programming language was developed by Sun Microsystems in the early 1990s. Although it is primarily used for Internet-based applications, Java is a simple, efficient, general-purpose language. Java was originally designed for embedded network applications running on multiple platforms.

Explanation:

Which Save As element allows a user to save a presentation on a computer?
Add a Place
OneDrive
Recent
This PC

Answers

Answer:

Option D, This PC allows a user to save a presentation on a computer

Explanation:

If one choses the option C, the file will be saved in the folder in which the user is working. Hence, option C is incorrect.

Like wise option A is also incorrect as it will require user to provide a location as option for saving the file

Option B is also incorrect as it will allow the user to save files in the C drive/D drive or one drive

Option D is correct because if the user choses this option file will be saved on the computer.

Hence option D is correct

Answer:

Option D : This PC allows a user to save a presentation on a computer

Explanation:

Edg 2021

In order to make burger a chef needs at least the following ingredients: • 1 piece of chicken meat • 3 lettuce leaves • 6 tomato slices Write down a formula to figure out how many burgers can be made. Get values of chicken meat, lettuce leaves and tomato slices from user. Hint: use Python’s built-in function

Answers

Answer:

how many burgers would you have to make ?

Explanation:

this is a question ot an answer

What is the molar mass of AuCI2

Answers

Answer:267.8726

Explanation:

3. Discuss microprocessor components, chips,
and specialty processors.


5. Define expansion slots, cards,including
graphics cards, network interface cards, wireless
network cards, and SD cards.​

Answers

Answer:

3

Microprocessor Components

Control Unit.

I/O Units.

Arithmetic Logic Unit (ALU)

Registers.

Cache.

The chips capacities express the word size, 16 bits, 32 bits, and 64 bits. The number of bits determined the amount of data it can process at one time

The specialty processors are specifically designed to handle special coprocessor and Graphics Processing Unit (GPU), like displaying 3D images or encrypting data.

5

slot machine, known variously as a fruit machine, puggy, the slots, poker machine/pokies, fruities or slots, is a gambling machine that creates a game of chance for its customers.

A video card (also called a graphics card, display card, graphics adapter, or display adapter) is an expansion card which generates a feed of output images to a display device (such as a computer monitor).

network interface controller is a computer hardware component that connects a computer to a computer network. Early network interface controllers were commonly implemented on expansion cards that plugged into a computer bus.

wireless network interface controller is a network interface controller which connects to a wireless network, such as Wi-Fi or Bluetooth, rather than a wired network, such as a Token Ring or Ethernet.

The standard SD card has dimensions of 32 mm by 24 mm by 2.1 mm, a storage capacity of up to 4 GB. Typical levels of performance are not as high as the other types of SD memory card mentioned below.

good luck!!!

A large computer repair company with several branches around Texas, TexTech Inc. (TTi), is looking to expand their business into retail. TTi plans to buy parts, assemble and sell computer equipment that includes desktops, monitors/displays, laptops, mobile phones and tablets. It also plans to sell maintenance plans for the equipment it sells that includes 90-day money back guarantee, 12-month cost-free repairs for any manufacturing defects, and annual subscription for repairs afterwards at $100 dollars per year. As part of a sales & marketing campaign to generate interest, TTi is looking to sell equipment in 5 different packages: 1. Desktop computer, monitor and printer 2. Laptop and printer 3. Phone and tablet 4. Laptop and Phone 5. Desktop computer, monitor and tablet TTi plans to sell these packages to consumers and to small-and-medium businesses (SMB). It also plans to offer 3-year lease terms to SMB customers wherein they can return all equipment to the company at the end of 3 years at no cost as long as they agree to enter into a new 3-year lease agreement. TTi has rented a warehouse to hold its inventory and entered into contracts with several manufacturers in China and Taiwan to obtain high-quality parts at a reasonable price. It has also hired 5 sales people and doubled its repair workforce to meet the anticipated increase in business. TTi has realized that it can no longer use Excel spreadsheets to meet their data and information needs. It is looking to use open source and has decided to develop an application using Python and MySQL. Your team has been brought in to design a database that can meet all of its data needs. Create a report that contains the following:

Required:
a. Data requirements of TTi: What are the critical data requirements based on your understanding of TTI business scenario described above.
b. Key Entities and their relationships
c. A conceptual data model in MySQL

Answers

Answer:

hecks

Explanation:

nah

A DNS TTL determines what?

Answers

Answer:

its time lapse and nod of serviaciation in between A and B. Each device connected will minus 1

Write a program which simulates the result of a person choosing 3 objects in a random order out of a box containing 3 objects in total. The box contains the following 3 objects: apple, ball, cat. A single selection pass of your program describes the random selection of 3 objects out of the box, without replacement. This means that a particular object can only be selected from the box once. At the beginning of a pass, the box is full, so it contains all 3 objects. After an object is selected from the box, your program will print the name of the object and then choose another object without replacing the previous object. The selection process repeats 3 times until the box is empty

Answers

Answer:

Explanation:

The following code is written in Python, it loops through a list (box) of the objects and randomly choosing one of the objects. Prints that object out and removes it from the list. Then repeats the process until the box is empty.

import random

box = ['apple', 'ball', 'cat']

print(box)

for x in range(len(box)):

   pick = random.randint(0,len(box)-1)

   print("Pick " + str(x+1) + ": " + box[pick])

   box.remove(box[pick])

print(box)

______ lets people access their stored data from a device that can access the Internet.
______ are programs that help people work and play online.

Answers

Answer:

Cloud computing and applications

Explanation:

Answer: Cloud computing

Applications

Explanation:

https://acm.cs.nthu.edu.tw/problem/13144/
The website is the problem, and I need to implement the 13144.h(which is function.h in the 13144.cpp) to get the right answer.
Thanks for your help.

Answers

Answer:

Th.. uh... yea... uh.. I don’t know

Explanation:

Because filling a pool/pond with water requires much more water than normal usage, your local city charges a special rate of $0.77 per cubic foot of water to fill a pool/pond. In addition, it charges a one-time fee of $100.00 for filling. This water department has requested you, as a programmer, write a C program that allows the user to enter a pool's length, width, and depth, in feet measurement. The program will then calculate the pool's volume, the volume of water needed to fill the pool with the water level 3 inches below the top, and the final cost of filling the pool, including the one-time fee. And then, all the entered sizes of the pool (in feet) and the three calculated values will be displayed on the screen. Finally, your full name as the programmer who wrote the program must be displayed at the end. To find the volume of the pool in cubic feet, use the formula: volume

Answers

Answer:

In C:

#include <stdio.h>

int main(){

   float length, width, depth,poolvolume,watervolume,charges;

   printf("Length (feet) : ");    scanf("%f",&length);

   printf("Width (feet) : ");    scanf("%f",&width);

   printf("Depth (feet) : ");    scanf("%f",&depth);

   poolvolume = length * width* depth;

   watervolume = length * width* (12 * depth - 3)/12;

   charges = 100 + 0.77 * watervolume;

   printf("Invoice");

   printf("\nVolume of the pool: %.2f",poolvolume);

   printf("\nAmount of the water needed: %.2f",watervolume);

   printf("\nCost: $%.2f",charges);

   printf("\nLength: %.2f",length);

   printf("\nWidth: %.2f",width);

   printf("\nDepth: %.2f",depth);

   printf("\nMr. Royal [Replace with your name] ");

   return 0;}

Explanation:

This declares the pool dimensions, the pool volume, the water volume and the charges as float    

float length, width, depth,poolvolume,watervolume,charges;

This gets input for length

   printf("Length (feet) : ");    scanf("%f",&length);

This gets input for width

   printf("Width (feet) : ");    scanf("%f",&width);

This gets input for depth

   printf("Depth (feet) : ");    scanf("%f",&depth);

This calculates the pool volume

   poolvolume = length * width* depth;

This calculates the amount of water needed

   watervolume = length * width* (12 * depth - 3)/12;

This calculates the charges

   charges = 100 + 0.77 * watervolume;

This prints the heading Invoice

printf("Invoice");

This prints the volume of the pool

   printf("\nVolume of the pool: %.2f",poolvolume);

This prints the amount of water needed

   printf("\nAmount of the water needed: %.2f",watervolume);

This prints the total charges

   printf("\nCost: $%.2f",charges);

This prints the inputted length

   printf("\nLength: %.2f",length);

This prints the inputted width

   printf("\nWidth: %.2f",width);

This prints the inputted depth

   printf("\nDepth: %.2f",depth);

This prints the name of the programmer

   printf("\nMr. Royal [Replace with your name] ");

   return 0;}

See attachment for program in text file

Create a class called Dot for storing information about a colored dot that appears on a flat grid. The class Dot will need to store information about its position (an x-coordinate and a y-coordinate, which should both be integers) and its color (which should be a string for now). You can choose what to call your attributes, but be sure to document them properly in the class's docstring.

Don't forget that every function definition, including method definitions, must have a docstring with a purpose statement and signature.

Answers

Answer:

Explanation:

The following class is written in Python, it has the three instance variables that were requested. It also contains a constructor that takes in those variables as arguments. Then it has functions to update the positions of the Dot and change its color. The class also has functions to output current position and color.

class Dot:

   """Class Dot"""

   x_coordinate = 0

   y_coordinate = 0

   color = ""

   def __init__(self, x_coordinate, y_coordinate, color):

       """Constructor that takes x and y coordinates as integers and a string for color. It ouputs nothing but saves these argument values into the corresponding instance variables."""

       self.x_coordinate = x_coordinate

       self.y_coordinate = y_coordinate

       self.color = color

   def moveUp(self, number_of_spaces):

       """Moves the Dot up a specific number of spaces that is passed as a parameter. Updates y_position"""

       self.y_coordinate += number_of_spaces

       return ""

   def moveDown(self, number_of_spaces):

       """Moves the Dot down a specific number of spaces that is passed as a parameter. Updates y_position"""

       self.y_coordinate -= number_of_spaces

       return ""

   def moveLeft(self, number_of_spaces):

       """Moves the Dot left a specific number of spaces that is passed as a parameter. Updates x_position"""

       self.x_coordinate -= number_of_spaces

       return ""

   def moveRight(self, number_of_spaces):

       """Moves the Dot right a specific number of spaces that is passed as a parameter. Updates x_position"""

       self.x_coordinate += number_of_spaces

       return ""

   def dot_position(self):

       """Print Dot Position"""

       print("Dot is in position: " + str(self.x_coordinate) + ", " + str(self.y_coordinate))

       return ""

   def dot_color(self):

       """Print Current Dot Color"""

       print("Dot color is: " + self.color)

what is the full from of CPU?​

Answers

Answer:

CPU is known as Central Processing Unit.

Full form? Like CPU meaning central processing unit?

Which describes the third step in visual character development?

Answers

3d model of a character is the third step

When the function below is called with 1 dependent and $400 as grossPay, what value is returned?

double computeWithholding (int dependents, double grossPay)

{
double withheldAmount;
if (dependents > 2)
withheldAmount = 0.15;
else if (dependents == 2)
withheldAmount = 0.18;
else if (dependnets == 1)
withheldAmount = 0.2;
else // no dependents
withheldAmount = 0.28;
withheldAmount = grossPay * withheldAmount;
return (withheldAmount);
}

a. 60.0
b. 80.0
c. 720.0
d. None of these

Answers

Answer:

b. 80.0

Explanation:

Given

[tex]dependent = 1[/tex]

[tex]grossPay = \$400[/tex]

Required

Determine the returned value

The following condition is true for: dependent = 1

else if (dependnets == 1)

withheldAmount = 0.2;

The returned value is calculated as:

[tex]withheldAmount = grossPay * withheldAmount;[/tex]

This gives:

[tex]withheldAmount = 400 * 0.2[/tex]

[tex]withheldAmount = 80.0[/tex]

Hence, the returned value is 80.0

Choose a problem that lends to an implementation that uses dynamic programming. Clearly state the problem and then provide high-level pseudocode for the algorithm. Explain why this algorithm can benefit from dynamic programming. Try to choose an algorithm different from any already posted by one of your classmates.

Answers

Answer:

Explanation:

The maximum weighted independent collection of vertices in a linear chain graph is a straightforward algorithm whereby dynamic programming comes in handy.

Provided a linear chain graph G = (V, E, W), where V is a collection of vertices, E is a set of edges margins, and W is a weight feature function applied to each verex.  Our goal is to find an independent collection of vertices in a linear chain graph with the highest total weight of vertices in that set.

We'll use dynamic programming to do this, with L[k] being the full weighted independent collection of vertices spanning from vertex 1 \to vertex k.

If we add vertex k+1 at vertex k+1, we cannot include vertex k, and thus L[k+1] would either be equivalent to L[k] when vertex k+1 is not being used, or L[k+1] = L[k-1] + W[k+1] when vertex k+1 is included.

[tex]Thus, L[k+1] = max \{ L[k], \ L[k-1] + W[k+1] \}[/tex]

As a result, the dynamic programming algorithm technique can be applied in the following way.

ALGO(V, W, n) // V is a linearly ordered series of n vertices with such a weight feature W

[tex]\text{1. L[0] = 0, L[1] = W[1], L[2] = max{W[1], W[2]} //Base cases} \\ \\ \text{2. For i = 3 to n:- \\} \\ \\\text{3........ if ( L[i-1] > L[i-2] + W[ i ] )} \\ \\ \text{4............Then L[ i ] = L[i-1]} \\ \\ \text{5.........else} \\ \\ \text{6................L[i] = L[i-2] + W[i] }\\ \\ \text{7. Return L[n] //our answer.}[/tex]

As a result, using dynamic programming, we can resolve the problem in O(n) only.

This is an example of a time-saving dynamic programming application.

The function leap n, which takes an integer n as input, and returns True if the year n is a leap year, and False otherwise. NOTE: Please provide function declaration [2 marks]. Leap years are those that are evenly divisible by 4, except any year that is also evenly divisible by 100 unless that year is also evenly divisible by 400. So, for example, 1996, 2012, and 2020 are all leap years, but 2100, 2200, and 2300 are not leap years, because although they are all evenly divisible by 4, they are also evenly divisible by 100. However, 1600, 2000, and 2400 are leap years, because although they are divisible by 100, they are also divisible by 400. The Haskell interaction may look like: > leap 1996 True > leap 2000 True > leap 2100 False

Answers

Answer:

Explanation:

The following code snippet is a leap year checker written in Haskell which checks to see if the year is a leap year and then outputs a boolean value.

isDivisibleBy :: Integral n => n -> n -> Bool

isDivisibleBy x n = x `rem` n == 0

leap_n :: Integer -> Bool

leap_n year

 | divBy 400 = True

 | divBy 100 = False

 | divBy   4 = True

 | otherwise = False

where

  divBy n = year `isDivisibleBy` n

Write the simulate method, which simulates the frog attempting to hop in a straight line to a goal from the frog's starting position of 0 within a maximum number of hops. The method returns true if the frog successfully reached the goal within the maximum number of hops; otherwise, the method returns false. TheFrogSimulationclass provides a method calledhopDistancethat returns an integer representing the distance (positive or negative) to be moved when the frog hops. A positive distance represents a move toward the goal. A negative distance represents a move away from the goal. The returned distance may vary from call to call. Each time the frog hops, its position is adjusted by the value returned by a call to thehopDistance method. g

Answers

Answer:

Explanation:

The following code is written in Python. It creates the simulate method which takes in an argument for the max number of hops and the goal distance. Then it loops the number for the max number of hops and asks the user for a hop input using the hopDistance() method (which was not included so it was made, this can be removed if wanted). Then it updates position. If after the max hops goal was reached it returns True, otherwise it returns False.

def simulate(max, goal):

   position = 0

   print("Goal is " + str(goal))

   for x in range(max):

       hop = hopDistance()

       position += int(hop)

   if position >= goal:

       return True

   else:

       return False

def hopDistance():

   return input("Frog Hop Distance this hop: ")

print(simulate(4, 20))

Other Questions
how to make art educational? Please Help! A bag contains four green marbles and five yellow marbles. You randomly select three marbles. What is the probability that all three marbles are green when (a) you replace each marble before selecting the next marble, and (b) you do not replace each marble before selecting the next marble? Write each probability as a decimal rounded to the nearest thousandth. Then compare the probabilities. How many members does the Senate have How is Yellowstone National Park affected by the supervolcano that lies beneath it? An example of hyperbole in this tall tale is Wheeler saying that Smileywhich in the following is the answer?will follow a bug to MexiconWins money on chicken fights.Will change sides in a bet.Almost always has good luck What is 12+[2-(4*a2)]7+b All of the following tasks are typically part of the revision process except:Acorrecting grammatical errorsBresearching the intended audienceCadding facts to strengthen an argumentDreading the essay aloud to identify awkward phrases help please ! thank u what type of Figurative Language is in hold fast in Hold Fast Your DreamsHELP HURRY YOU WILL GET BRAINLYEST A credit card company decides to study the frequency with which its cardholders charge for items from a certain change of retail stores. The data values collected in the study appear to be normally distributed with a mean of 25 charged purchases and a standard distribution of 2 charged purchases. Out of the total number of cardholders about hw many would you expect are charging 27 or more in the study Mabel Livingston is clearly guilty of hiring a private detective to cover up her sons crimes. This led to property damage and left her son free to make trouble. However, Ms. Livingston is an elderly woman. She has a long history of supporting charities and the community. She seems to care about people and is not likely to hurt them intentionally.Prosecutors could charge Ms. Livingston with crimes such as obstruction of justice or conspiracy to destroy evidence. In most states, a typical sentence for those crimes would involve up to a $1,000 fine and up to six months in jail.What are the pros and cons of sending Ms. Livingston to jail? Please, Help!!!!!!!!!!!!!!!! Find the value of c that makes x2 + 6x + c a perfect square. Then write the trinomial as a perfect square. Using one of the sentence starters below, write a short summary of "Letter from a Birmingham Jall."Dr. King came to Birmingham because...Dr. King did not belleve In walting for racism to gradually end because...Dr. King believed that in the future...The rhetoric that Dr. King uses is... Scott paid 10.47 for a 6.08 - kg bag of dog food. A few weeks later, he paid 13.88 for a7.48 -kg bag at a different store. Find the unit price for each bag. Then state which bag is the better buy based on the unit price. Round your answers to the nearest cent. What does 49/100 + 4/10 equal The following schemes show the design of a peptide-based chemical probe and the proposed mechanism of its activity-based labeling of protein tyrosine phosphatase, an enzyme that is responsible for removing the phosphate from the tyrosine residue(s) of a peptide in a peptide-sequence specific manner. Based your understanding of the schemes and the relevant lecture material, identify the key structural components of this probe that are responsible for (a) binding, (b) covalently modifying, and (c) reporting, respectively. I NEED HELP, PLEASE AND THANK YOU! The force you apply to a machine is called the what force? Eliza got a box of chocolates for Valentine'sDay. The box contains 25 chocolates. Thechocolates are not labeled, so she has noidea what kind each one is, but she knowsthat there are 5 that contain peanuts. IfEliza randomly picks two chocolates to eatfrom the box, what is the probability thatthe first has peanuts and the second doesnot?