Home » Java Programing Assignment

Java Programing Assignment

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:

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

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

Save Time On Research and Writing
Hire a Pro to Write You a 100% Plagiarism-Free Paper.
Get My Paper

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); } }

Place your order
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more
Live Chat+1 763 309 4299EmailWhatsApp

We Can Handle your Online Class from as low as$100 per week