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


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 9 of 9

Thread: Need help solving this Java program excerise

  1. #1
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Exclamation 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 = ?????


  2. #2
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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 = ?????

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,619
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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. #5
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,619
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default 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.
    If you don't understand my answer, don't ignore it, ask a question.

  6. #6
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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. #7
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,619
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Need help solving this Java program excerise

    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.
    If you don't understand my answer, don't ignore it, ask a question.

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

    DuaneLewis (January 31st, 2013)

  9. #8
    Junior Member
    Join Date
    Jan 2013
    Posts
    5
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default 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. #9
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    18,619
    Thanks
    45
    Thanked 1,958 Times in 1,932 Posts

    Default Re: Need help solving this Java program excerise

    Have you tried searching here on the forum? There are many examples of code here.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Thank you for solving the mystery!!
    By Maxi in forum Member Introductions
    Replies: 1
    Last Post: September 19th, 2012, 07:41 PM
  2. Help with solving Maze
    By tcao2 in forum Algorithms & Recursion
    Replies: 9
    Last Post: May 5th, 2012, 08:58 PM
  3. I REALLY NEED HELP IN SOLVING THIS ROCK PAPER SCISSOR
    By John93 in forum Java Theory & Questions
    Replies: 12
    Last Post: April 8th, 2012, 08:55 PM
  4. Solving a polynomial
    By arvindbis in forum Java Theory & Questions
    Replies: 9
    Last Post: March 7th, 2012, 11:16 PM
  5. Problem in recursion for Solving Maze Recursively program
    By _Coder1985 in forum Algorithms & Recursion
    Replies: 1
    Last Post: April 29th, 2009, 04:37 AM

Tags for this Thread