# Need help solving this Java program excerise

• January 31st, 2013, 03:45 PM
DuaneLewis
Need help solving this Java program excerise
Assignment objectives:
- Input / output
- Decision making statements
- Loops
- Methods

Shoot a watermelon from a cannon and write a program in JAVA to compute the following given the initial velocity and initial angle of trajectory:

1. Maximum horizontal distance
2. Maximum vertical distance
3. Total travel time
4. Elapsed time when it reaches maximum vertical distance
5. In addition if there is an obstacle in its path, would the cannon ball clear it or not.
Initial velocity, initial angle (in degrees), the obstacle distance from the canon and the height of the obstacle is given by the user, use any way you like to ask for the data.
The user must be allowed to try different set of inputs as many times as desired.

Formuals are;

x = vcos(x) * t
y= vcos(x) * t - (g*t/2)

Angles are in radians for the formals

Conversion :

Requirements:
1. You must use methods for each of the above calculations.
2. You must use Dialog box for inputs from the user
3. Check the validity of input data

Sample output:
Initial velocity = ???
Initial angle = ????
Obstacle distance from the anon = ????
Obstacle height = ?????
Maximum horizontal distance = ?????
• January 31st, 2013, 03:47 PM
DuaneLewis
Good Evening, need help with Java code
Assignment objectives:
- Input / output
- Decision making statements
- Loops
- Methods

Shoot a watermelon from a cannon and write a program in JAVA to compute the following given the initial velocity and initial angle of trajectory:

1. Maximum horizontal distance
2. Maximum vertical distance
3. Total travel time
4. Elapsed time when it reaches maximum vertical distance
5. In addition if there is an obstacle in its path, would the cannon ball clear it or not.
Initial velocity, initial angle (in degrees), the obstacle distance from the canon and the height of the obstacle is given by the user, use any way you like to ask for the data.
The user must be allowed to try different set of inputs as many times as desired.

Formuals are;

x = vcos(x) * t
y= vcos(x) * t - (g*t/2)

Angles are in radians for the formals

Conversion :

Requirements:
1. You must use methods for each of the above calculations.
2. You must use Dialog box for inputs from the user
3. Check the validity of input data

Sample output:
Initial velocity = ???
Initial angle = ????
Obstacle distance from the anon = ????
Obstacle height = ?????
Maximum horizontal distance = ?????
• January 31st, 2013, 03:48 PM
Norm
Re: Need help solving this Java program excerise
• January 31st, 2013, 04:01 PM
DuaneLewis
Re: Need help solving this Java program excerise
Yes I am very new to Java programming and I think this site would be very helpful to help guide me on the correct path. This is my first course I am taking regarding the program. I have no clue on how to set up the correct methods for this program, can you please help me I am so confuse, thank you.
• January 31st, 2013, 04:29 PM
Norm
Re: Need help solving this Java program excerise
Here's some links with info on how to write a method:
Defining Methods (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Passing Information to a Method or a Constructor (The Java™ Tutorials > Learning the Java Language > Classes and Objects)
Returning a Value from a Method (The Java™ Tutorials > Learning the Java Language > Classes and Objects)

Before writing any code, you need to make a list of the simple steps that the program needs to do to solve the problem. Then work on the steps one at a time: Code it, compile it, fix errors and execute it.
Then move to the next step in the list.
• January 31st, 2013, 04:54 PM
DuaneLewis
Re: Need help solving this Java program excerise
Thank you so much and by any chance can you please help me with the first part of the set up of getting started with computing the following given the initial velocity and initial angle of trajectory or asking for the input so the user can put different set of inputs as many times as desired, thank you
• January 31st, 2013, 05:19 PM
Norm
Re: Need help solving this Java program excerise
Quote: