Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2. Ball Trajectory Game Write a MATLAB program to create a game that prompts user to enter the speed and angle with which a ball

image text in transcribed
2. Ball Trajectory Game Write a MATLAB program to create a game that prompts user to enter the speed and angle with which a ball is thrown to hit a randomly placed target The height h) and horizontal distance x() traveled by a ball thrown at an angle A and speed v are given by the following equations h() - vrsin A- gr/2 x(t) vt cos A The acceleration due to gravity is g = 9.81 m/sec. The user gets three tries to hit a target with a ball. Your program should solve the following problems: Create a target (a small square) on the ground at a random distance from origin and display this value to the user Prompt the user to enter the value of initial velocity v between 0 and 100 m/ sec and angle A between 0 and 90 degrees. If the user enters a value that lies outside these bounds, prompt the user to re-enter that value. Use the values of v and A to numerically calculate and plot the ball's trajectory (plot h versus x for positive values of h). Use the axis command to restrict the height to positive values. Find the maximum distance xmax traveled by the ball. a. b. c. d. Plot the trajectory for the given values of v and A e. Check whether the ball has landed at a location that is at distance +0.25 m from target. If yes, it is a hit. If the ball hits the target successfully, the program should display "Hit" and exit; otherwise, it should display "Miss" and continue until three tries are up Note: Run the program in the file lab7p to see how your program should work Output Format: Your program must display the location of the target and the trajectory created by the ball when it is thrown each time

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Essentials of Database Management

Authors: Jeffrey A. Hoffer, Heikki Topi, Ramesh Venkataraman

1st edition

133405680, 9780133547702 , 978-0133405682

More Books

Students also viewed these Databases questions

Question

Define a copyright and identify what a copyright can protect.

Answered: 1 week ago

Question

How do Data Types perform data validation?

Answered: 1 week ago

Question

How does Referential Integrity work?

Answered: 1 week ago