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
Ad libitum [116K]
3 years ago
10

Write the simulate method, which simulates the frog attempting to hop in a straight line to a goal from the frog's starting posi

tion 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
Computers and Technology
1 answer:
Anvisha [2.4K]3 years ago
4 0

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))

You might be interested in
Which of the following does not correctly declare an ArrayList?
kotegsom [21]

Answer:

Option b. ArrayList‹Integer› = new ArrayList‹Integer›(10) does not correctly declare an ArrayList.

<u>Explanation</u>:

ArrayList in Java dynamically stores elements in it. It also called as re- sizeable array as it expands  in size when elements are added and decreases when an element is removed from it. This array list class also allows to use duplicate and null values.

The syntax for creating Array list is as follows

ArrayList<Type> obj = new ArrayList<Type>()

Type  specifies the type of ArrayList like Integer, Character, Boolean etc, and obj is the object name. But in the option b ArrayList‹Integer› = new ArrayList‹Integer›(10)  object name is missed and not specified.

6 0
3 years ago
During the system investigation stage, __________ studies are done to determine if the hardware, software, and communications co
oksano4ka [1.4K]

Answer:

The correct answer is "Technical Feasibility".

Explanation:

System investigation is used to Review that whether the system is feasible or not for the proposal that they will design or creating.in the system investigation stage, we do the technical feasibility. The technical feasibility is used to check technical resources like hardware, software, etc in the organization.

The  Technical Feasibility in the System investigation  is used to solve the problem of business

6 0
4 years ago
Mecanismo que permite conocer si la persona que esta ingresando a un sistema es realmente quien deba y no un intruso
Tems11 [23]

Answer:

Sistemas de autenticación y seguridad de la información.

Explicación:

La seguridad de la información es un mecanismo que permite saber si la persona que está ingresando a un sistema es realmente quien debería y no un intruso. La seguridad de la información básicamente ayuda a prevenir el acceso no autorizado y permite que la única persona autorizada ingrese al sistema. Los sistemas de autenticación son el mecanismo de seguridad que se utiliza para proteger los datos y los sistemas. Estos sistemas de autenticación también ayudan a garantizar que los usuarios sean la persona autorizada o no.

4 0
3 years ago
From 1995 to 1997, the number of web users
BigorU [14]
Quadrupled. I think sorry if you get it wrong i do not remember much
7 0
3 years ago
Read 2 more answers
In a bubble sort for a list of length n &gt;= 2, in each iteration, the first step is to compare_______.
Hunter-Best [27]

Answer:

the consecutive two elements and swap them based on the value which is larger if we go for ascending order

Explanation:

bubble sort compares 2 consecutive elements of the list and swap them. in one iteration one value will be placed correctly depending on the sorting order either ascending or descending

7 0
3 years ago
Other questions:
  • A user is claiming a host can be reached via the IP address but not through the name. What should a technician do first to resol
    13·1 answer
  • Why should you use a named constant for the size of an array?
    9·1 answer
  • The process of using a computer to write, design, and assemble documents is called A. desktop publishing. B. scanning. C. consul
    7·1 answer
  • Is the ability to use digital tools for reading communicating and learning online?​
    5·1 answer
  • If you said the bottom margin, you are talking about what?
    13·2 answers
  • How do you write a multiplication formula in excel with an absolute refrence?
    11·1 answer
  • Observe the following statements and decide whether the variable result’s value is TRUE or FALSE.
    13·1 answer
  • The price of an item you want to buy is given in dollars and cents. You pay for it in cash by giving the clerk d dollars and c c
    6·1 answer
  • A program that converts a program to binary all at once and runs the entire program when finished with the conversion.
    5·1 answer
  • What is the objective of Accenture‘s e-stewards program
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!