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
Reil [10]
3 years ago
5

Write a program to provide information on the height of a ball thrown straight up into the air. The program should request as in

put the initial height, h feet, and the initial velocity, v feet per second. The height of the ball after t seconds is
Computers and Technology
2 answers:
Ymorist [56]3 years ago
7 0

Answer:

The height of the ball after t seconds is h + vt - 16t 2 feet:

def main():

getInput()

def getInput():

h = int(input("Enter the initial height of the ball: ")) # Adding the int keyword before input() function

v = int(input("Enter the initial velocity of the ball: ")) # Same as above

isValid(h,v)

def isValid(h,v):

if ((h <= 0) or (v <= 0)):

print("Please enter positive values")

getInput()

else:

maxHeight(h,v)

def maxHeight(h,v):

t = (v/32)

maxH = (h + (v*h) - (16*t*t))

print ("\nMax Height of the Ball is: " + str(maxH) + " feet")

ballTime(h, v)

def ballTime(h,v):

t = 0

ballHeight = (h + (v*t) - (16*t*t))

while (ballHeight >= 0):

t += 0.1

ballHeight = (h + (v*t) - (16*t*t))

print ("\nThe ball will hit the ground approximately after " + str(t) + " seconds")

# Driver Code

main()

IgorC [24]3 years ago
4 0

Answer:

I am writing a python code.

def getInput():

   h = int(input("enter the height: "))

   v = int(input("enter the velocity: "))

   isValid(h,v)    

def isValid(h,v):

   if (h<= 0 or v<=0):

       print("not positive ")            

   else:

       height = maximumHeight(h,v)

       print("maximum height of the ball is", height," ft.")

       balltime = ground_time(h,v)

       print("The ball will hit the ground after", balltime, "s approximately.")

def maximumHeight(h,v):

   t = (v/32)

   maxheight = (h + (v*t) - (16*t*t))

   return maxheight    

def ground_time(h,v):

   t = 0.1

   while(True):

       heightofball = (h + (v*t) - (16*t*t))

       if (heightofball <= 0):

           break

       else:

           t += 0.1  

   return t

Explanation:

There are four functions in this program.

getInput() function is used to take input from the user which is height and velocity. h holds  the value of height and v holds the value of velocity. input() function is used to accept values from the user.

isValid() function is called after the user enters the value of height and velocity. This function first checks if the value of height and velocity is less than 0. If it is true the message not positive is displayed. If its false then maximumHeight() is called which returns the maximum height of the ball and function ground_time() is called to return the time when the ball will hit the ground.

maximumHeight() function first divides the value of velocity with 32 as the ball will reach its maximum  height after v/32 seconds. It then returns the maximum height by using the formula:  heightofball = (h + (v*t) - (16*t*t)).

ground_time() calculates the time the ball takes to reach the ground. There is a while loop to height after every 0.1 second and determine when the height is no longer a positive . It uses (h + (v*t) - (16*t*t)) formula to calculate the height and when the value of height gets less than or equal to 0 the loop terminates otherwise it keeps calculating the height while adding 1 to the value of t at each iteration. After the loop breaks, it returns the value of t.

To see the output of the maximum height and time taken by ball to reach the ground, you can call the getInput() function at the end of the above program as:

getInput()

Output:

enter the height: 9

enter the velocity: 10

maximum height of the ball is 10.6525  ft.

the ball will hit the ground after 1.2 s approximately.

You might be interested in
Which statement is LEAST accurate? Select one: a. A common reason for ERP failure is that the ERP does not support one or more i
Fittoniya [83]

Answer:

d. To take full advantage of the ERP process, re-engineering will need to occur.

Explanation:

Justification:  

ERP Implementation: ERP gives a change in technological ways for managing resources, the way to run the business is remained same but now Ft becomes well planned Diversified P units of Mich do not share common process. and data, generally employ phased-in approach of implementing ERP

• It is the way to overcome from the risk which is with the big bang approach, direct switching

• Perfect implementation of ERP needs re-engineering on the basis of performance

a. maintenance Sometimes ERP which is installed could not support one of the business process. due to lack of research before selecting it

• The statement that the diversified organizations. not. implement ERPs is least accurate because they implement it by employing phased-in approach Therefore, the correct option is d

3 0
4 years ago
Which are guidlines for using themes? Check all that apply
Andreyy89

Answer: A. Using different cell styles can help you differentiate different types of data.

B. Fonts should be easily readable and of appropriate size.

D. Be consistent with themes across worksheets and workbooks.

Explanation:

A theme refers to the preset package that contains functionality details and graphical appearance.

The guidelines for using themes include:

• Using different cell styles can help you differentiate different types of data.

• Fonts should be easily readable and of appropriate size.

• Be consistent with themes across worksheets and workbooks.

Therefore, the correct options are A, B and D.

7 0
3 years ago
Which of the following is the last step in creating a budget?
sweet [91]
You answer to the question is C
3 0
3 years ago
Excel solver is the only method that one can utilize for automated linear programming solutions. True or False
klasskru [66]

Answer:

False

Explanation:

This is not true at all. This can be done with a wide variety of resources in the modern world. There is the CPLEX (IBM ILOG CPLEX Optimization Studio) software, which was developed by Robert E. Bixby in 1988, it passed to several other companies and it was later sold to IBM in January 2009. Today it's one of the world's most effective programs when it comes to automated linear programming solutions.

3 0
3 years ago
Allen needs a program that injects automatically semi-random data into a program or stack and detects bugs. What will he use?
Goryan [66]

Answer:

A) fuzzer

Explanation:

From the question, we are informed that Allen needs a program that injects automatically semi-random data into a program or stack and detects bugs. In this case,he will use a fuzzer. A fuzzer can be regarded as a program that gives in a semi-random data to a program/stack, and it will detect bug. fuzzing testing can be regarded as

software testing process which discover bugs in the software, this is done automatically by giving in input of randomized data to the computer program. Generation of data is done by a generator, while vulnerability identification depends on the tools use in the debugging process.

8 0
3 years ago
Other questions:
  • If you turn your volume to loud on u'r headphones can it break the sound quality of the speaker?
    9·2 answers
  • One of the best examples of outcome control is the re-hiring of Steve Jobs by Apple as CEO
    14·1 answer
  • If you combine two cells into one, what action are you performing?
    12·2 answers
  • Which is a disadvantage ofsimulation?
    5·1 answer
  • The following code processes a file containing five positive numbers. What will the variable $result contain after the code is e
    13·1 answer
  • Write a for loop that sets each array element in bonusScores to the sum of itself and the next element, except for the last elem
    11·2 answers
  • What do you think is the importance of Science Technology and Society​
    8·1 answer
  • Question #1
    5·2 answers
  • Why do we use if statements?
    9·1 answer
  • Dealing with stress and strong emotions centeral idea​
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!