Question
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...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started