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

Thread: java homework help

  1. #1
    Junior Member
    Join Date
    Apr 2021
    Posts
    2
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default java homework help

    Hello everyone i am stuck on this assignment can someone help


    Ask the user to input four pairs of x,y coordinates in this format:

    x0 y0 x1 y1 x2 y2 x3 y3

    Use the SimplePoint class below and add a main() method to it. The main() method should create a SimplePoint object for each pair of x,y coordinates. Next, it should determine which of the four points is furthest from point 0,0. Finally, the main() method should output the x,y coordinates of the furthest point, along with the distance. Match the sample run below.

    Here is the SimplePoint class:

    public class SimplePoint {

    private double x,y;

    public SimplePoint(double x1, double y1) {
    x = x1;
    y = y1;
    }

    public double getX() { return x; };

    public double getY() { return y; };

    public double distance(SimplePoint p) {
    return Math.sqrt( Math.pow(p.getX()-x,2) + Math.pow(p.getY()-y,2) );
    }

    }

  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,162
    Thanks
    65
    Thanked 2,725 Times in 2,675 Posts

    Default Re: java homework help

    What problems are you having? Do you have any specific java programming questions?

    Please edit your post and wrap your code with code tags:

    [code]
    **YOUR CODE GOES HERE**
    [/code]

    to get highlighting and preserve formatting.
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Java Homework Help
    By newbieCode in forum What's Wrong With My Code?
    Replies: 5
    Last Post: October 1st, 2018, 09:42 AM
  2. Java Homework
    By Dimo62 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: October 8th, 2013, 11:57 AM
  3. Replies: 8
    Last Post: February 12th, 2013, 05:45 AM
  4. Really new to Java, need some help with some homework
    By vanillabilla in forum Java Theory & Questions
    Replies: 1
    Last Post: November 14th, 2012, 11:01 PM
  5. New to Java Need help with Homework
    By cjg2283 in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 20th, 2011, 09:47 PM

Tags for this Thread