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 :
radian=( degree * 3.14)/180
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 = ?????
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 :
radian=( degree * 3.14)/180
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 = ?????
Re: Need help solving this Java program excerise
Do you have any specific questions about your assignment?
Please post your code and any questions about problems you are having.
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.
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)
If you have any specific questions about your assignment, post them.
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.
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
Re: Need help solving this Java program excerise
Quote:
asking for the input
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.
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
Re: Need help solving this Java program excerise
Have you tried searching here on the forum? There are many examples of code here.