Welcome to the Java Programming Forums

The professional, friendly Java community. 21,500 members and growing!

The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.

>> REGISTER NOW TO START POSTING

Thread: Need help solving this Java program excerise

1. 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 = ?????

2. 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 = ?????

4. 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.

5. 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.

6. 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

7. Re: Need help solving this Java program excerise

You ask a question with a call to the println() method that will display a message on the console
and read the user's keyed in response with a method of the Scanner class.

8. The Following User Says Thank You to Norm For This Useful Post:

DuaneLewis (January 31st, 2013)

9. Re: Need help solving this Java program excerise

Im sorry I am really new to this, can you please show me a random example of asking a question with a call to the println() method

10. Re: Need help solving this Java program excerise

Have you tried searching here on the forum? There are many examples of code here.