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 8 of 8

Thread: Program not working - assistance please

  1. #1
    Junior Member
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Program not working - assistance please

    I have gone over and over this code. I still get errors when I check it with an online java tester. It is simple. Please help. Thanks.


    import java.util.Scanner;

    public class coordinate
    {
    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in);

    // Enter a point with two double values
    System.out.print("Enter a point with two coordinates: ");
    double x = input.nextDouble();
    double y = input.nextDouble();

    // Compute the horizontal distance to the center of the rectangle
    double hDistance = Math.pow(x * x, 0.5);

    // Compute the vertical distance to the center of the rectangle
    double vDistance = Math.pow(y * y, 0.5);

    if (hDistance <= 5 || vDistance <= 2.5)
    System.out.println("Point (" + x + ", " + y +
    ") is in the rectangle");
    else
    System.out.println("Point (" + x + ", " + y +
    ") is not in the rectangle");
    }
    }


  2. #2
    Junior Member
    Join Date
    Jan 2014
    Posts
    3
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Coordinates within a rectangle

    I have tried this several different ways. Could someone please tell me what is wrong with this code? Thank you.

    import java.util.Scanner;

    public class Coordinates
    {
    public static void main(String[] args)
    {
    Scanner input = new Scanner(System.in);

    // Enter a point with two double values
    System.out.print("Enter a point with two coordinates: ");
    double x = input.nextDouble();
    double y = input.nextDouble();

    // Compute the horizontal distance to the center of the rectangle
    double hDistance = Math.pow(x * x, 0.5);

    // Compute the vertical distance to the center of the rectangle
    double vDistance = Math.pow(y * y, 0.5);

    if (hDistance <= 5 || vDistance <= 2.5)
    System.out.println("Point (" + x + ", " + y +
    ") is in the rectangle");
    else
    System.out.println("Point (" + x + ", " + y +
    ") is not in the rectangle");
    }
    }

  3. #3
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,139
    Thanks
    65
    Thanked 2,720 Times in 2,670 Posts

    Default Re: Program not working - assistance please

    I still get errors
    Please copy the full text of the errors and paste it here.

    Please edit your post and wrap your code with code tags:
    [code=java]
    YOUR CODE HERE
    [/code]
    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

  4. #4
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: Coordinates within a rectangle

    We can't really tell you what's wrong with it if you don't tell us what it does wrong. Does it compile? Does it run? Does it exhibit some strange behavior? Something else?
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #5
    Super Moderator
    Join Date
    Jun 2013
    Location
    So. Maryland, USA
    Posts
    5,517
    My Mood
    Mellow
    Thanks
    215
    Thanked 698 Times in 680 Posts

    Default Re: Program not working - assistance please

    Please don't post multiple threads on the same topic. To learn other simple house rules, please read this topic.

  6. #6
    Member Ganeprog's Avatar
    Join Date
    Jan 2014
    Location
    Chennai,India
    Posts
    80
    My Mood
    Love
    Thanks
    3
    Thanked 6 Times in 6 Posts

    Default Re: Program not working - assistance please

    Hi,

    Please tell me what is your expected output. Post the errors what you are getting.

    Happy to help

    Thanks,

  7. #7
    Junior Member
    Join Date
    Jan 2014
    Posts
    23
    My Mood
    Mellow
    Thanks
    0
    Thanked 1 Time in 1 Post

    Default Re: Program not working - assistance please

    code is rite .. you just chk the process to run that code..

  8. #8
    Junior Member
    Join Date
    Jan 2014
    Posts
    14
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default Re: Program not working - assistance please

    There is no problem in your code, you must try to compile it using java compiler instead of online java application tester.
    the program is working great for me after i tested it.

Similar Threads

  1. [SOLVED] Java assignment creating a game program need assistance
    By joeyzx in forum What's Wrong With My Code?
    Replies: 0
    Last Post: August 31st, 2013, 08:23 PM
  2. Replies: 2
    Last Post: October 16th, 2012, 10:13 PM
  3. NEED ASSISTANCE W/ JAVA PROGRAM
    By Neddrick in forum What's Wrong With My Code?
    Replies: 0
    Last Post: April 29th, 2010, 08:20 PM
  4. array program assistance needed
    By JavaNoob82 in forum Collections and Generics
    Replies: 4
    Last Post: December 14th, 2009, 05:49 AM
  5. Replies: 5
    Last Post: December 13th, 2009, 07:10 PM