Based off of the methods I wrote I need you to create a Class named Projectile and then Create a client to test it. You must incorporate the following criteria.create a class named Projectile with the following private instance
variables:
double velocity
double seconds
double angle
double height
double distance
Your class should contain the following public methods:
* a three argument constructor that accepts the velocity, seconds, and angle
from the client and places these values into the corresponding instance
variables.
* a set and get method for each instance variable
public double getVel()
public double getHeight()
public double getSecs()
public double getAngle()
public double getDistance()
private setVel(double v)
private setSecs(double s)
private setAngle(double a)
private setHeight(double h)
private setDistance(double d)
and two additional methods:
double calcDistance()
//calculates the distance, stores this into the private instance
//variable distance, and returns this value to the client
double calcHeight()
//calculates the height, stores this into the private instance
//variable height, and returns this value to the client
The calcHeight and calcDistance methods should calculate height and
distance according to the formulas from assignment #1 and they should
use the get methods to obtain the values for Velocity, seconds, and angle
where necessary.
You can test your implementation of Projectile by coping and running
TestProjectile.java from the class directory. The command to copy this
file is:
cp /home2/classes/csi205/TestProjectile.java TestProjectile.java
Compile and run TestProjectile. This is a client program that will
use and test your Projectile class and methods.
You should submit your Projectile.java file with the following command:
turnin-csi205 -c csi205 -p prog2 Projectile.java
Notes:
-Include Comments in your code and format your program neatly. Remember to
include your name and Student ID# in your comments. Comment your
variables and provide comments in each of your public methods
-All variables you use for mathematical computations should be of type
double
-The name of the file which you save your application, and hence the class
name, should be named
Projectile.java. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ Then for the Client~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ From assignments #1 & #2, we know that we can determine the height and distance
of a projectile based on its initial angle and velocity. We can also calculate the
projectiles X and Y coordinates (it’s x and y velocity) based on it’s initial
angle and velocity.
The x coordinate is calculated as velocity * cos(angle)
The y coordinate is calculated as velocity * sin(angle)
Additionally, we can calculate the half-time of flight (the amount of time that
passes from the launch till the projectile is at the top of its trajectory) as
y-coordinate/gravity-constant and the maximum height of the projectile as
y-coordinate * half-time + 0.5 * (gravity-constant * -1) * half-time**2.
Modify your assignment #2 to include the following additional double private data
fields: xcoordinate, ycoordinate, halftime, and maxheight. You should create get
and set methods for these additional fields. Additional methods you should create
for Projectile are:
1. calcX – calculate the x coordinate based on the velocity and angle
2. calcY – calculate the y coordinate based on the velocity and angle
3. calcHalf – calculate the half-time based on the y-coordinate and
gravity_constant
4. calcMaxheight – calculate the maximum height based on the y-coordinate,
half-time, and gravity_constant
Where needed, these methods should use the get methods to retrieve values from
the private data fields.
You should also create a client/test program that produces the same output as
assignment #2, with the addition of the x and y coordinates, the half time and
the maximum height.
This client should run in a “loop”, allowing the user to enter values for angle,
velocity and seconds and printing the calculated values for distance, height,
x & y coordinates, half time and maximum height until the user enters an angle
of -1 (at which point the program terminates) This client program should be named
TestProjectile.java. The client should use System.out.print/println and nextDouble()
to display prompts/output on the screen and to obtain input from the keyboard.
All specifications for assignment #2 remain in effect. Rember to comment both the
Projectile and TestProjectile classes.~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~`~~~~~It won’t let me attach the code so I’m going to paste my methods here./ This program displays the height and distance of a projectile at a given moment in time based on // take off angle and initial velocity.import java.util.*; public class Projectile { // Initializing my Scanner. public static void main(String[] args) { Scanner console = new Scanner(System.in); System.out.println(“This program displays the Height and distance”); System.out.println(” of a projectile at a given moment in time”); System.out.println(” for any given takeoff angle and initial velocity”); // declaring the variable they have to input. System.out.print(“Initial Velocity (m/s): “); double velocity = console.nextDouble(); System.out.print(“Takeoff angle in degrees: “); double angle = Math.toRadians(console.nextDouble()); System.out.print(“Seconds into flight: “); float seconds = console.nextFloat(); double distance = velocity * Math.cos(angle)* seconds; double g = 9.8; / double velocityfactor = velocity * Math.sin(angle)*seconds; double height = -0.5 *g* Math.pow(seconds, 2) + velocityfactor; System.out.println(“After ” + seconds + ” seconds, the projectile is at (in meters) “); System.out.printf (” Height: %.2f n Distance: %.2f ” , height, distance); } }
Why Work with Us
Top Quality and Well-Researched Papers
We always make sure that writers follow all your instructions precisely. You can choose your academic level: high school, college/university or professional, and we will assign a writer who has a respective degree.
Professional and Experienced Academic Writers
We have a team of professional writers with experience in academic and business writing. Many are native speakers and able to perform any task for which you need help.
Free Unlimited Revisions
If you think we missed something, send your order for a free revision. You have 10 days to submit the order for review after you have received the final document. You can do this yourself after logging into your personal account or by contacting our support.
Prompt Delivery and 100% Money-Back-Guarantee
All papers are always delivered on time. In case we need more time to master your paper, we may contact you regarding the deadline extension. In case you cannot provide us with more time, a 100% refund is guaranteed.
Original & Confidential
We use several writing tools checks to ensure that all documents you receive are free from plagiarism. Our editors carefully review all quotations in the text. We also promise maximum confidentiality in all of our services.
24/7 Customer Support
Our support agents are available 24 hours a day 7 days a week and committed to providing you with the best customer experience. Get in touch whenever you need any assistance.
Try it now!
How it works?
Follow these simple steps to get your paper done
Place your order
Fill in the order form and provide all details of your assignment.
Proceed with the payment
Choose the payment system that suits you most.
Receive the final file
Once your paper is ready, we will email it to you.
Our Services
No need to work on your paper at night. Sleep tight, we will cover your back. We offer all kinds of writing services.
Essays
No matter what kind of academic paper you need and how urgent you need it, you are welcome to choose your academic level and the type of your paper at an affordable price. We take care of all your paper needs and give a 24/7 customer care support system.
Admissions
Admission Essays & Business Writing Help
An admission essay is an essay or other written statement by a candidate, often a potential student enrolling in a college, university, or graduate school. You can be rest assurred that through our service we will write the best admission essay for you.
Reviews
Editing Support
Our academic writers and editors make the necessary changes to your paper so that it is polished. We also format your document by correctly quoting the sources and creating reference lists in the formats APA, Harvard, MLA, Chicago / Turabian.
Reviews
Revision Support
If you think your paper could be improved, you can request a review. In this case, your paper will be checked by the writer or assigned to an editor. You can use this option as many times as you see fit. This is free because we want you to be completely satisfied with the service offered.