import java.util.*;  
import java.math.*;

public class Euler {
    public int diffy;
    public int diffx;
    public double initialx;
    public double initialy;
    public double finalx;
    public int increment;
    public double derivative;
    public double deltax;
    public double deltay;
    public static void wholethingig() {
        Scanner in = new Scanner(System.in);  // Create a Scanner object
        System.out.println("what is the coefficient of y in dy/dx = x + y");
        int diffy = in.nextInt();  // Read user input
        System.out.println("what is coefficient of x in dy/dx = x + y");
        int diffx = in.nextInt();  // Read user input
        System.out.println("what is the starting x coordinate");
        double initialx = in.nextDouble();  // Read user input
        System.out.println("what is the starting y coordinate");
        double initialy = in.nextDouble();  // Read user input
        System.out.println("what is the final x coordinate");
        double finalx = in.nextDouble();  // Read user input
        System.out.println("how many increments");
        int increment = in.nextInt();
        System.out.println("Equation is: dy/dx = " + diffx + "x"  + " + " + diffy + "y");
        System.out.println("Starting coordinate = " + "(" + initialx + ", " + initialy + ")");
        System.out.println(increment + " increments to get to f(" + finalx + ")");
        double deltax = (finalx - initialx)/increment;
        System.out.println(deltax);
        for (int i = 0; i < increment; i++ ) {
            double derivative = (initialx * diffx) + (initialy * diffy);
            double deltay = derivative * deltax;
            System.out.println("(x,y) = " + "(" + initialx + ", " + initialy + ")   |   " + "Delta x = " + deltax + "   |   " + "dy/dx = " + derivative + "   |   " + "deltax * (dy/dx) = " + deltay + "   |   " + "delta x(dy/dx) = " + deltay + "   |   " + "((x + dx), (y + dy))" + " = (" + initialx + ", " + initialy + ")"); 
            // System.out.println("Delta x = " + deltax + ".");
            // System.out.println("dy/dx = " + derivative + ".");
            // System.out.println("delta x(dy/dx) = " + deltay + ".");
            // System.out.println("((x + dx), (y + dy))" + " = (" + initialx + ", " + initialy + ")");
            // System.out.println(deltax);
            initialy = initialy + deltay;
            initialx = initialx + deltax; 
            // System.out.println("diffx = " + diffx);
            // System.out.println("diffy = " + diffy);
            // System.out.println("derivative = " + derivative);
            // System.out.println("finalx = " + initialx);
        }
    System.out.println("Final approximation using Euler's method: (" + initialx + ", " + initialy + ")");
    }
    public static void main(String[] args) {
        wholethingig();
        // getDeltaX();
    }
}
Euler.main(null);
what is the coefficient of y in dy/dx = x + y
what is coefficient of x in dy/dx = x + y
what is the starting x coordinate
what is the starting y coordinate
what is the final x coordinate
how many increments
Equation is: dy/dx = 1x + -2y
Starting coordinate = (2.0, 1.0)
3 increments to get to f(1.7)
-0.10000000000000002
(x,y) = (2.0, 1.0)   |   Delta x = -0.10000000000000002   |   dy/dx = 0.0   |   deltax * (dy/dx) = -0.0   |   delta x(dy/dx) = -0.0   |   ((x + dx), (y + dy)) = (2.0, 1.0)
(x,y) = (1.9, 1.0)   |   Delta x = -0.10000000000000002   |   dy/dx = -0.10000000000000009   |   deltax * (dy/dx) = 0.01000000000000001   |   delta x(dy/dx) = 0.01000000000000001   |   ((x + dx), (y + dy)) = (1.9, 1.0)
(x,y) = (1.7999999999999998, 1.01)   |   Delta x = -0.10000000000000002   |   dy/dx = -0.2200000000000002   |   deltax * (dy/dx) = 0.022000000000000023   |   delta x(dy/dx) = 0.022000000000000023   |   ((x + dx), (y + dy)) = (1.7999999999999998, 1.01)
Final approximation using Euler's method: (1.6999999999999997, 1.032)