How do I use a point class, rational number class, and line class to Solve a system of 2 linear equations?

185 views Asked by At

I am fairly new to computer science and have been trying, unsuccessfully, to use a point class, a line class, and a Rational number class in order to solve a System of linear equations. The code for the System is old and I'm adapting it to work for the new one I'm making but I can't, for the life of me, debug/work-through one section of the code(the relates to the rest so if I can't do one I can't do all and the whole code doesn't work) at oneChosenFirst(). I'm not seeking the complete code but a very simplified explanation as to how to properly do this, thank you. Here is what i have in systems so far. the systems is based on user inputs too.

My Systems of Linear equations for slope and a y intercept:

public static void oneChosenFirst() {

    System.out.println("Enter values for Y intercept (0,#). ");
    double A = scn.nextDouble();
    double B = scn.nextDouble();
    Point Yint1 = new Point();
    System.out.println("Enter values for slope (Rise/Run). ");
    Line slope1 = new Line();
    }

Once again, many thanks, anything you think may help me on my journey through java is much appreciated.

1

There are 1 answers

1
Vitruvie On

To solve a system of linear equations geometrically (as with your point and line classes), represent each equation as a line, and then the solution to the system is the point at which these lines intersect. If you are having difficulty with a particular step of this process, please say so and show what you've tried so far to accomplish that step.