Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this assignment you are going to write a program that simulates what happens when a ball is thrown at a particular angle and initial

For this assignment you are going to write a program that simulates what happens when a ball is thrown at a particular angle and initial velocity.

You will need to Make a class called Ball that keeps track of the status of the ball at a given time, and updates that status as time passes. In addition you must create a main class called YourlastnameAssign4.java (with your actual last name) that runs the simulation given input from the user.

Your Ball class should have the following private fields, all of which should be doubles:

  • hDist - the horizontal distance from the point where the ball was thrown in meters.
  • vDist - the vertical distance of the ball from the ground in meters.
  • hSpeed - how fast the ball is travelling horizontally in meters per second.
  • vSpeed - how fast the ball is travelling vertically in meters per second.

Your Ball class should also have the the following public methods:

public void initialize(double angle, double velocity, double height) - sets up the initial conditions as follows:

  • The horizontal distance should be set to 0.
  • The vertical distance should be set to height.
  • The horizontal speed should be set to velocity multiplied by Math.cos(Math.toRadians(angle)).
  • The vertical speed should be set to velocity multiplied by Math.sin(Math.toRadians(angle)).

Step by Step Solution

3.43 Rating (150 Votes )

There are 3 Steps involved in it

Step: 1

Absolutely heres the code for the Ball class and the YourLastNameAssign4java class to simulate a ball thrown at an angle Balljava java public class Ba... 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_2

Step: 3

blur-text-image_3

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

Tax Research

Authors: Barbara H. Karlin

4th Edition

013601531X, 978-0136015314

More Books

Students also viewed these Programming questions

Question

How do functional silos prevent process integration?

Answered: 1 week ago