Chat with us, powered by LiveChat Java Programing Assignment | Writedemy

Java Programing Assignment

Java Programing Assignment

Question

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

Our website has a team of professional writers who can help you write any of your homework. They will write your papers from scratch. We also have a team of editors just to make sure all papers are of HIGH QUALITY & PLAGIARISM FREE. To make an Order you only need to click Ask A Question and we will direct you to our Order Page at WriteDemy. Then fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Fill in all the assignment paper details that are required in the order form with the standard information being the page count, deadline, academic level and type of paper. It is advisable to have this information at hand so that you can quickly fill in the necessary information needed in the form for the essay writer to be immediately assigned to your writing project. Make payment for the custom essay order to enable us to assign a suitable writer to your order. Payments are made through Paypal on a secured billing page. Finally, sit back and relax.

Do you need an answer to this or any other questions?

About Writedemy

We are a professional paper writing website. If you have searched a question and bumped into our website just know you are in the right place to get help in your coursework. We offer HIGH QUALITY & PLAGIARISM FREE Papers.

How It Works

To make an Order you only need to click on “Order Now” and we will direct you to our Order Page. Fill Our Order Form with all your assignment instructions. Select your deadline and pay for your paper. You will get it few hours before your set deadline.

Are there Discounts?

All new clients are eligible for 20% off in their first Order. Our payment method is safe and secure.

Hire a tutor today CLICK HERE to make your first order